<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- 
	Copyright (C) 2007, 2008, 2009, 2010, 2011. PARP Research Group.
	<http://perception.inf.um.es>
	University of Murcia, Spain.

	This file is part of the QVision library.

	QVision is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation, version 3 of the License.

	QVision is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with QVision. If not, see <http://www.gnu.org/licenses/>.
-->

<html><head><meta http-equiv="content-Type" content="text/html;charset=UTF-8">
<title>QVision: Qt&#39;s Image, Video and Computer Vision Library</title>
<meta name="title" content="QVision" />
<meta name="dc.title" content="QVision" />
<meta name="url" content="http://perception.inf.um.es/QVision" />
<meta name="author" content="PARP Research Group - http://perception.inf.um.es" />
<meta name="revisit-after" content="30 DAYS"/>
<meta name="robots" content="index,follow"/>
<meta name="classification" content="*">
<meta name="rating" content="Safe For Kids">
<meta name="distribution" content="GLOBAL"/>
<meta name="description" content="Qt's Image, Video and Computer Vision Library"/>
<meta name="page-topic" content="Computer Vision research and prototype programming"/>
<meta name="geo.country" content="ES" />

<!--
Keywords:
By license:		open source, gnu, lgpl, gpl, free
By theme:		computer vision, image processing, robotics, programming, source, development
By usage:		library, toolkit, framework, prototype, application
By programming specs:	object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping
Interoperability with:	Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack
Functionallity:		image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface
Main data-types:	matrix, vector, tensor, quaternion, image, polyline
Video sources:		webcam, camera, stream
Devices:		embedded, desktop computer, laptop, mini-laptop
Authors:		PARP research group. University of Murcia, Spain.
-->

<meta name="keywords" content="augmented reality, sfm, structure from motion, open source, gnu, lgpl, gpl, free, computer vision, image processing, robotics, programming, source, development, library, toolkit, framework, prototype, application, object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping, Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack, image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface, matrix, vector, tensor, quaternion, image, polyline, webcam, camera, stream, embedded, desktop computer, laptop, mini-laptop, University of Murcia, Spain, PARP research group, vision por computador"/>
<meta http-equiv="keywords" content="augmented reality, sfm, structure from motion, open source, gnu, lgpl, gpl, free, computer vision, image processing, robotics, programming, source, development, library, toolkit, framework, prototype, application, object oriented, c++, block programming, reusability, gui, graphical, parallel computing, high performance, GPU, prototyping, Qt, GSL, GNU Scientific library, OpenCV, CGAL, QWT, CUDA, mplayer, IPP, Intel Image Performance Primitives, blas, lapack, image features, matrix algebra, projective geometry, mser, function minimization, function optimization, canny operator, harris operator, corner detection, performance evaluation, cpu usage, graphical interface, matrix, vector, tensor, quaternion, image, polyline, webcam, camera, stream, embedded, desktop computer, laptop, mini-laptop, University of Murcia, Spain, PARP research group, vision por computador"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="title" content="QVision"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" />
</head><body>

<table width="100%"><tr>
	<td><a href="http://perception.inf.um.es/"><img src="parp.png" border="0" /> <big>PARP Research Group</big></a></td>
	<td align="right"><a href="http://www.um.es/"><big>Universidad de Murcia</big> <img src="um.png" border="0" /></a></td>
</tr></table>

<hr /><br />

<table width="95%" align="center"><tr><td>

<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
          <form id="FSearchBox" action="search.php" method="get">
            <img id="MSearchSelect" src="search/search.png" alt=""/>
            <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" 
                   onfocus="searchBox.OnSearchFieldFocus(true)" 
                   onblur="searchBox.OnSearchFieldFocus(false)"/>
          </form>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>src/qvmath/qvmatrix.cpp</h1><a href="qvmatrix_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *      Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012. PARP Research Group.</span>
<a name="l00003"></a>00003 <span class="comment"> *      &lt;http://perception.inf.um.es&gt;</span>
<a name="l00004"></a>00004 <span class="comment"> *      University of Murcia, Spain.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> *      This file is part of the QVision library.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *      QVision is free software: you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> *      it under the terms of the GNU Lesser General Public License as</span>
<a name="l00010"></a>00010 <span class="comment"> *      published by the Free Software Foundation, version 3 of the License.</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> *      QVision is distributed in the hope that it will be useful,</span>
<a name="l00013"></a>00013 <span class="comment"> *      but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00014"></a>00014 <span class="comment"> *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00015"></a>00015 <span class="comment"> *      GNU Lesser General Public License for more details.</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> *      You should have received a copy of the GNU Lesser General Public</span>
<a name="l00018"></a>00018 <span class="comment"> *      License along with QVision. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020 
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;limits&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;qvmath.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;<a class="code" href="qvdefines_8h.html" title="File from the QVision library.">qvdefines.h</a>&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;qvmatrixalgebra.h&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;QString&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;QVMatrix&gt;</span>
<a name="l00034"></a>00034 
<a name="l00036"></a>00036 <span class="comment">// Constructors</span>
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3">00038</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>():
<a name="l00039"></a>00039         cols(1), rows(1), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00040"></a>00040         {
<a name="l00041"></a>00041         <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(0,0) = 1;
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043 
<a name="l00044"></a><a class="code" href="classQVMatrix.html#abc05373f1061e5bcc5a2b14c4935b87f">00044</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix):
<a name="l00045"></a>00045         cols(matrix.cols), rows(matrix.rows), type(matrix.type), transposed(matrix.type), data(matrix.data)
<a name="l00046"></a>00046         { }
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="classQVMatrix.html#aa1e79567d85632f3bdfbe5168ef75c19">00048</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> rows, <span class="keyword">const</span> <span class="keywordtype">int</span> cols, <span class="keyword">const</span> <span class="keywordtype">double</span> *data):
<a name="l00049"></a>00049         cols(cols), rows(rows), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00050"></a>00050         {
<a name="l00051"></a>00051         <span class="keywordflow">if</span> (data != NULL)
<a name="l00052"></a>00052                 {
<a name="l00053"></a>00053                 <span class="keyword">const</span> <span class="keywordtype">int</span> n = cols*rows;
<a name="l00054"></a>00054                 <span class="keywordtype">double</span> *matrixData = <a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00055"></a>00055                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; n; i++)
<a name="l00056"></a>00056                         matrixData[i] = data[i];
<a name="l00057"></a>00057                 }
<a name="l00058"></a>00058                 <span class="comment">//for (int r = 0; r &lt; rows; r++)</span>
<a name="l00059"></a>00059                 <span class="comment">//      for (int c = 0; c &lt; cols; c++)</span>
<a name="l00060"></a>00060                 <span class="comment">//              operator()(r, c) = data[r*cols + c];</span>
<a name="l00061"></a>00061         }
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="classQVMatrix.html#a4aab4e157f144cc043814c6d5b99c869">00063</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> rows, <span class="keyword">const</span> <span class="keywordtype">int</span> cols, <span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;data):
<a name="l00064"></a>00064         cols(cols), rows(rows), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00065"></a>00065         {
<a name="l00066"></a>00066         <span class="keyword">const</span> <span class="keywordtype">int</span> n = cols*rows;
<a name="l00067"></a>00067         <span class="keywordtype">double</span> *matrixData = <a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00068"></a>00068         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; n; i++)
<a name="l00069"></a>00069                 matrixData[i] = data[i];
<a name="l00070"></a>00070         }
<a name="l00071"></a>00071 
<a name="l00072"></a>00072 
<a name="l00073"></a><a class="code" href="classQVMatrix.html#ac6d8176e71a0767469156d10f8b469d9">00073</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> rows, <span class="keyword">const</span> <span class="keywordtype">int</span> cols, <span class="keyword">const</span> <span class="keywordtype">double</span> value):
<a name="l00074"></a>00074         cols(cols), rows(rows), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00075"></a>00075         {
<a name="l00076"></a>00076         <span class="keyword">set</span>(value);
<a name="l00077"></a>00077         }
<a name="l00078"></a>00078 
<a name="l00079"></a><a class="code" href="classQVMatrix.html#a790874f74bdbebb42ba4e9b36bdfc9a1">00079</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <a class="code" href="classQVQuaternion.html" title="Implementation of quaternions.">QVQuaternion</a> &amp;quaternion)
<a name="l00080"></a>00080         {
<a name="l00081"></a>00081         *<span class="keyword">this</span> = quaternion.<a class="code" href="classQVQuaternion.html#a00c343b8018cfc98536b13ff31341751" title="Gets the rotation matrix corresponding to the Quaternion.">toRotationMatrix</a>();
<a name="l00082"></a>00082         }
<a name="l00083"></a>00083 
<a name="l00084"></a><a class="code" href="classQVMatrix.html#af9a2ca831ea15352d53859a5ba817913">00084</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;vector, <span class="keyword">const</span> <span class="keywordtype">bool</span> rowVector):
<a name="l00085"></a>00085         cols(rowVector?vector.size():1), rows(rowVector?1:vector.size()), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00086"></a>00086         {
<a name="l00087"></a>00087         <span class="keywordflow">if</span> (rowVector)
<a name="l00088"></a>00088                 <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(0, vector);
<a name="l00089"></a>00089         <span class="keywordflow">else</span>
<a name="l00090"></a>00090                 <a class="code" href="classQVMatrix.html#a8ebc03603ced1c727afd6f3bd755e57a" title="Sets a column of the matrix.">setCol</a>(0, vector);
<a name="l00091"></a>00091         }
<a name="l00092"></a>00092 
<a name="l00093"></a><a class="code" href="classQVMatrix.html#a55959c258761e9433040492bf0caf879">00093</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> QList&lt;QVVector&gt; &amp;vectorList): cols(vectorList.at(0).size()), rows(vectorList.size()), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00094"></a>00094         {
<a name="l00095"></a>00095         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(); n++)
<a name="l00096"></a>00096                 {
<a name="l00097"></a>00097                 Q_ASSERT(vectorList.at(n).size() == <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00098"></a>00098                 <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(n, vectorList.at(n));
<a name="l00099"></a>00099                 }
<a name="l00100"></a>00100         }
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="classQVMatrix.html#a187cdf22594a555e1e165938dffdabf8">00102</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> QList&lt; QVector&lt;double&gt; &gt; &amp;vectorList): cols(vectorList.at(0).size()), rows(vectorList.size()), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00103"></a>00103         {
<a name="l00104"></a>00104         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(); n++)
<a name="l00105"></a>00105                 {
<a name="l00106"></a>00106                 Q_ASSERT(vectorList.at(n).size() == <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00107"></a>00107                 <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(n, vectorList.at(n));
<a name="l00108"></a>00108                 }
<a name="l00109"></a>00109         }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 <span class="preprocessor">#ifdef GSL_AVAILABLE</span>
<a name="l00112"></a><a class="code" href="classQVMatrix.html#a9c3be8f1d2a66325aa725f870af88a2d">00112</a> <span class="preprocessor"></span><a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> gsl_matrix *matrix): cols(matrix-&gt;size2), rows(matrix-&gt;size1), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00113"></a>00113         {
<a name="l00114"></a>00114         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00115"></a>00115                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00116"></a>00116                         <span class="keyword">operator</span>()(i, j) = gsl_matrix_get(matrix, i, j);
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118 
<a name="l00119"></a><a class="code" href="classQVMatrix.html#aeb271c920414baa68078052cd263d391">00119</a> <a class="code" href="classQVMatrix.html#aeb271c920414baa68078052cd263d391" title="Convert to a gsl_matrix * operator.">QVMatrix::operator gsl_matrix * </a>()<span class="keyword"> const</span>
<a name="l00120"></a>00120 <span class="keyword">        </span>{
<a name="l00121"></a>00121         gsl_matrix *result = gsl_matrix_alloc(rows, cols);
<a name="l00122"></a>00122         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00123"></a>00123                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00124"></a>00124                         gsl_matrix_set(result, i, j, <span class="keyword">operator</span>()(i, j));
<a name="l00125"></a>00125         <span class="keywordflow">return</span> result;
<a name="l00126"></a>00126         }
<a name="l00127"></a>00127 <span class="preprocessor">#endif</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span>
<a name="l00129"></a><a class="code" href="classQVMatrix.html#a9d5b767dd336700c292ad9aac40c6314">00129</a> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> QList&lt;QPointF&gt; &amp;pointList): cols(2), rows(pointList.size()), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00130"></a>00130         {
<a name="l00131"></a>00131         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(); n++)
<a name="l00132"></a>00132                 <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(n, pointList.at(n));
<a name="l00133"></a>00133         }
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 <span class="preprocessor">#ifdef QVOPENCV</span>
<a name="l00136"></a><a class="code" href="classQVMatrix.html#a17dd731d484d852109fd76b7b23b7861">00136</a> <span class="preprocessor"></span><a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> CvMat *cvMatrix): cols(cvMatrix-&gt;cols), rows(cvMatrix-&gt;rows), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00137"></a>00137         {
<a name="l00138"></a>00138         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00139"></a>00139                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00140"></a>00140                                 this-&gt;<span class="keyword">operator</span>()(i,j) = cvmGet(cvMatrix, i, j);
<a name="l00141"></a>00141         }
<a name="l00142"></a>00142 
<a name="l00143"></a><a class="code" href="classQVMatrix.html#a129ef6e4e7854e7faa11234ac6686239">00143</a> CvMat *<a class="code" href="classQVMatrix.html#a129ef6e4e7854e7faa11234ac6686239" title="Converts the matrix to an OpenCV matrix structure.">QVMatrix::toCvMat</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> cvMatType)<span class="keyword"> const</span>
<a name="l00144"></a>00144 <span class="keyword">        </span>{
<a name="l00145"></a>00145         Q_ASSERT( (cvMatType == CV_32F) || (cvMatType == CV_64F) );
<a name="l00146"></a>00146 
<a name="l00147"></a>00147         CvMat *result = cvCreateMat(rows, cols, cvMatType);
<a name="l00148"></a>00148 
<a name="l00149"></a>00149         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00150"></a>00150                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00151"></a>00151                                 cvmSet(result, i, j, this-&gt;<span class="keyword">operator</span>()(i,j));
<a name="l00152"></a>00152         <span class="keywordflow">return</span> result;
<a name="l00153"></a>00153         }
<a name="l00154"></a>00154 <span class="preprocessor">#endif</span>
<a name="l00155"></a>00155 <span class="preprocessor"></span>
<a name="l00156"></a>00156 <span class="preprocessor">#ifdef QVOCTAVE</span>
<a name="l00157"></a>00157 <span class="preprocessor"></span><a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix::QVMatrix</a>(<span class="keyword">const</span> Matrix octMatrix): cols(octMatrix.columns()), rows(octMatrix.rows()), type(General), transposed(false), data(new QBlasDataBuffer(cols*rows))
<a name="l00158"></a>00158         {
<a name="l00159"></a>00159         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00160"></a>00160                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00161"></a>00161                         <span class="keyword">operator</span>()(i,j) = octMatrix(i,j);
<a name="l00162"></a>00162         }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164 Matrix QVMatrix::toOctaveMat()<span class="keyword"> const</span>
<a name="l00165"></a>00165 <span class="keyword">        </span>{
<a name="l00166"></a>00166         Matrix result(rows, cols);
<a name="l00167"></a>00167 
<a name="l00168"></a>00168         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00169"></a>00169                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00170"></a>00170                         result(i,j) = <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,j);
<a name="l00171"></a>00171         <span class="keywordflow">return</span> result;
<a name="l00172"></a>00172         }
<a name="l00173"></a>00173 <span class="preprocessor">#endif</span>
<a name="l00174"></a>00174 <span class="preprocessor"></span>
<a name="l00176"></a><a class="code" href="classQVMatrix.html#ad8121ca66a84f9d804f2e52764dc0fac">00176</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp; <a class="code" href="classQVMatrix.html#ad8121ca66a84f9d804f2e52764dc0fac" title="Copy operator.">QVMatrix::operator=</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l00177"></a>00177         {
<a name="l00178"></a>00178         cols = matrix.cols;
<a name="l00179"></a>00179         rows = matrix.rows;
<a name="l00180"></a>00180         type = matrix.type;
<a name="l00181"></a>00181         transposed = matrix.transposed;
<a name="l00182"></a>00182         data = matrix.data;
<a name="l00183"></a>00183 
<a name="l00184"></a>00184         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00185"></a>00185         }
<a name="l00186"></a>00186 
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 <span class="comment">/*QVVector QVMatrix::operator*(const QVVector &amp;vector) const</span>
<a name="l00190"></a>00190 <span class="comment">        {</span>
<a name="l00191"></a>00191 <span class="comment">        Q_ASSERT(vector.size() == getCols());</span>
<a name="l00192"></a>00192 <span class="comment">        // Todo: use blas for this function</span>
<a name="l00193"></a>00193 <span class="comment">        return dotProduct(vector.toColumnMatrix()).getCol(0);</span>
<a name="l00194"></a>00194 <span class="comment">        }*/</span>
<a name="l00195"></a>00195 
<a name="l00197"></a>00197 
<a name="l00198"></a><a class="code" href="classQVMatrix.html#ad93605cfaa45a37fe579a709d3707ddf">00198</a> <span class="keywordtype">bool</span> <a class="code" href="classQVMatrix.html#ad93605cfaa45a37fe579a709d3707ddf" title="Matrix-matrix equality operator.">QVMatrix::equals</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00199"></a>00199 <span class="keyword">        </span>{
<a name="l00200"></a>00200         <span class="comment">// Check valences for both matrixs are equivalent</span>
<a name="l00201"></a>00201         <span class="keywordflow">if</span> (cols != matrix.cols || rows != matrix.rows)
<a name="l00202"></a>00202                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00203"></a>00203 
<a name="l00204"></a>00204         <span class="comment">// Check data in both matrixs is equal</span>
<a name="l00205"></a>00205         <span class="keyword">const</span> <span class="keywordtype">double</span>    *data1 = <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(),
<a name="l00206"></a>00206                                 *data2 = matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00207"></a>00207 
<a name="l00208"></a>00208         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>(); i++)
<a name="l00209"></a>00209                 <span class="keywordflow">if</span> (data1[i] != data2[i])
<a name="l00210"></a>00210                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00213"></a>00213         }
<a name="l00214"></a>00214 
<a name="l00215"></a>00215 <span class="preprocessor">#ifdef BLAS_AVAILABLE</span>
<a name="l00216"></a><a class="code" href="classQVMatrix.html#a2b08927830e95af327187580ba1875fc">00216</a> <span class="preprocessor"></span><a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#a5470e61c2827d5485596c3901690154c" title="Matrix-matrix product.">QVMatrix::dotProduct</a>(<span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;vector, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeMatrix)<span class="keyword"> const</span>
<a name="l00217"></a>00217 <span class="keyword">        </span>{
<a name="l00218"></a>00218         <span class="keyword">const</span> <span class="keywordtype">int</span>       m = transposeMatrix? cols: rows,
<a name="l00219"></a>00219                         n = transposeMatrix? rows: cols,
<a name="l00220"></a>00220                         n_ = vector.size();
<a name="l00221"></a>00221 
<a name="l00222"></a>00222         <span class="keywordflow">if</span> (n != n_)
<a name="l00223"></a>00223                 {
<a name="l00224"></a>00224                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to multiply a matrix with a vector of incompatible sizes at QVMatrix::dotProduct(const QVVector &amp;v).&quot;</span> &lt;&lt; std::endl
<a name="l00225"></a>00225                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix dimensions:\t&quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; n &lt;&lt; std::endl
<a name="l00226"></a>00226                         &lt;&lt; <span class="stringliteral">&quot;\tVector dimension:\t&quot;</span> &lt;&lt; n_ &lt;&lt; std::endl;
<a name="l00227"></a>00227                 exit(1);
<a name="l00228"></a>00228                 }
<a name="l00229"></a>00229 
<a name="l00230"></a>00230         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result(m);
<a name="l00231"></a>00231         cblas_dgemv(CblasRowMajor, transposeMatrix?CblasTrans:CblasNoTrans, rows, cols, 1.0, <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(), cols, vector.data(), 1, 0.0, result.data(), 1);
<a name="l00232"></a>00232         <span class="keywordflow">return</span> result;
<a name="l00233"></a>00233         }
<a name="l00234"></a>00234 
<a name="l00235"></a><a class="code" href="classQVMatrix.html#a5470e61c2827d5485596c3901690154c">00235</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a5470e61c2827d5485596c3901690154c" title="Matrix-matrix product.">QVMatrix::dotProduct</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeFirstOperand, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeSecondOperand)<span class="keyword"> const</span>
<a name="l00236"></a>00236 <span class="keyword">        </span>{
<a name="l00237"></a>00237         <span class="comment">//std::cout &lt;&lt; &quot;** gsl&quot; &lt;&lt; std::endl;</span>
<a name="l00238"></a>00238         <span class="keyword">const</span> <span class="keywordtype">int</span> cols1 = cols, rows1 = rows, cols2 = matrix.cols, rows2 = matrix.rows;
<a name="l00239"></a>00239 
<a name="l00240"></a>00240         <span class="comment">// C_mxn = A_mxk * B_kxn</span>
<a name="l00241"></a>00241         <span class="keyword">const</span> <span class="keywordtype">int</span>       m = transposeFirstOperand? cols1: rows1,
<a name="l00242"></a>00242                         k = transposeFirstOperand? rows1: cols1,
<a name="l00243"></a>00243                         k_ = transposeSecondOperand? cols2: rows2,
<a name="l00244"></a>00244                         n = transposeSecondOperand? rows2: cols2;
<a name="l00245"></a>00245 
<a name="l00246"></a>00246         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(m, n);
<a name="l00247"></a>00247 
<a name="l00248"></a>00248         <span class="comment">// Ensure k == k_</span>
<a name="l00249"></a>00249         Q_ASSERT(k == k_);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         <span class="keywordflow">if</span> (k != k_)
<a name="l00252"></a>00252                 {
<a name="l00253"></a>00253                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to multiply matrices with incompatible sizes at QVMatrix::dotProduct(const QVMatrix &amp;matrix).&quot;</span> &lt;&lt; std::endl
<a name="l00254"></a>00254                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 1 dimensions:\t&quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; k &lt;&lt; std::endl
<a name="l00255"></a>00255                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 2 dimensions:\t&quot;</span> &lt;&lt; k_ &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; n &lt;&lt; std::endl;
<a name="l00256"></a>00256                 exit(1);
<a name="l00257"></a>00257                 }
<a name="l00258"></a>00258  
<a name="l00259"></a>00259         cblas_dgemm(CblasRowMajor,
<a name="l00260"></a>00260                         transposeFirstOperand?CblasTrans:CblasNoTrans,
<a name="l00261"></a>00261                         transposeSecondOperand?CblasTrans:CblasNoTrans,
<a name="l00262"></a>00262                         m, n, k, 1.0,
<a name="l00263"></a>00263                         <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(), cols1,
<a name="l00264"></a>00264                         matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(), cols2, 0.0,
<a name="l00265"></a>00265                         result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>(), n);
<a name="l00266"></a>00266 
<a name="l00267"></a>00267         <span class="keywordflow">return</span> result;
<a name="l00268"></a>00268         }
<a name="l00269"></a>00269 <span class="preprocessor">#else</span>
<a name="l00270"></a>00270 <span class="preprocessor"></span><a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a5470e61c2827d5485596c3901690154c" title="Matrix-matrix product.">QVMatrix::dotProduct</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeFirstOperand, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeSecondOperand)<span class="keyword"> const</span>
<a name="l00271"></a>00271 <span class="keyword">        </span>{
<a name="l00272"></a>00272         std::cout &lt;&lt; <span class="stringliteral">&quot;[QVMatrix::dotProduct] --------------------------------- Not blas! --------------------&quot;</span> &lt;&lt; std::endl;
<a name="l00273"></a>00273         <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a>  op1 = transposeFirstOperand? this-&gt;<a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e" title="Change the order of the indexes in the matrix.">transpose</a>():(*this),
<a name="l00274"></a>00274                         op2 = transposeSecondOperand? matrix.transpose():matrix;
<a name="l00275"></a>00275 
<a name="l00276"></a>00276         <span class="keyword">const</span> <span class="keywordtype">int</span> m = op1.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), o = op1.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), o_ = op2.getRows(), n = op2.getCols();
<a name="l00277"></a>00277 
<a name="l00278"></a>00278         <span class="comment">// Ensure k == k_</span>
<a name="l00279"></a>00279         Q_ASSERT(o == o_);
<a name="l00280"></a>00280 
<a name="l00281"></a>00281         <span class="keywordflow">if</span> (o != o_)
<a name="l00282"></a>00282                 {
<a name="l00283"></a>00283                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to multiply matrices with incompatible sizes at QVMatrix::dotProduct(const QVMatrix &amp;matrix).&quot;</span> &lt;&lt; std::endl
<a name="l00284"></a>00284                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 1 dimensions:\t&quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; o &lt;&lt; std::endl
<a name="l00285"></a>00285                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 2 dimensions:\t&quot;</span> &lt;&lt; o_ &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; n &lt;&lt; std::endl;
<a name="l00286"></a>00286                 exit(1);
<a name="l00287"></a>00287                 }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(m, n, 0.0);
<a name="l00290"></a>00290 
<a name="l00291"></a>00291         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; m; i++)
<a name="l00292"></a>00292                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j = 0; j &lt; n; j++)
<a name="l00293"></a>00293                         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> k = 0; k &lt; o; k++)
<a name="l00294"></a>00294                                 result(i,j) += op1(i,k) * op2(k, j);
<a name="l00295"></a>00295         <span class="keywordflow">return</span> result;
<a name="l00296"></a>00296         }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298 <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#a5470e61c2827d5485596c3901690154c" title="Matrix-matrix product.">QVMatrix::dotProduct</a>(<span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;vector, <span class="keyword">const</span> <span class="keywordtype">bool</span> transposeMatrix)<span class="keyword"> const</span>
<a name="l00299"></a>00299 <span class="keyword">        </span>{
<a name="l00300"></a>00300         std::cout &lt;&lt; <span class="stringliteral">&quot;[QVMatrix::dotProduct] --------------------------------- Not blas! --------------------&quot;</span> &lt;&lt; std::endl;
<a name="l00301"></a>00301         <span class="comment">//std::cout &lt;&lt; &quot;not gsl&quot; &lt;&lt; std::endl;</span>
<a name="l00302"></a>00302         <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a>  op1 = transposeMatrix? this-&gt;<a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e" title="Change the order of the indexes in the matrix.">transpose</a>() : (*this);
<a name="l00303"></a>00303         <span class="keyword">const</span> <span class="keywordtype">int</span> m = op1.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), o = op1.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), o_ = vector.size();
<a name="l00304"></a>00304 
<a name="l00305"></a>00305         <span class="keywordflow">if</span> (o != o_)
<a name="l00306"></a>00306                 {
<a name="l00307"></a>00307                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to multiply a matrix with a vector of incompatible sizes at QVMatrix::dotProduct(const QVVector &amp;v).&quot;</span> &lt;&lt; std::endl
<a name="l00308"></a>00308                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix dimensions:\t&quot;</span> &lt;&lt; m &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; o &lt;&lt; std::endl
<a name="l00309"></a>00309                         &lt;&lt; <span class="stringliteral">&quot;\tVector dimension:\t&quot;</span> &lt;&lt; o_ &lt;&lt; std::endl;
<a name="l00310"></a>00310                 exit(1);
<a name="l00311"></a>00311                 }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result(m, 0.0);
<a name="l00314"></a>00314 
<a name="l00315"></a>00315         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; m; i++)
<a name="l00316"></a>00316                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> k = 0; k &lt; o; k++)
<a name="l00317"></a>00317                         result[i] += op1(i,k) * vector[k];
<a name="l00318"></a>00318 
<a name="l00319"></a>00319         <span class="keywordflow">return</span> result;
<a name="l00320"></a>00320         }
<a name="l00321"></a>00321 <span class="preprocessor">#endif</span>
<a name="l00322"></a>00322 <span class="preprocessor"></span>
<a name="l00323"></a><a class="code" href="classQVMatrix.html#a30f99ef8af0ff9f3997143d389698b71">00323</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a30f99ef8af0ff9f3997143d389698b71" title="Matrix-matrix element product.">QVMatrix::elementProduct</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00324"></a>00324 <span class="keyword">        </span>{
<a name="l00325"></a>00325         <span class="keyword">const</span> <span class="keywordtype">int</span> cols1 = cols, rows1 = rows, cols2 = matrix.cols, rows2 = matrix.rows;
<a name="l00326"></a>00326 
<a name="l00327"></a>00327         Q_ASSERT(rows1 == rows2);
<a name="l00328"></a>00328         Q_ASSERT(cols1 == cols2);
<a name="l00329"></a>00329 
<a name="l00330"></a>00330         <span class="keywordflow">if</span> (cols1 != cols2 || rows1 != rows2)
<a name="l00331"></a>00331                 {
<a name="l00332"></a>00332                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to multiply matrices with incompatible sizes at QVMatrix::dotProduct(const QVMatrix &amp;matrix).&quot;</span> &lt;&lt; std::endl
<a name="l00333"></a>00333                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 1 dimensions:\t&quot;</span> &lt;&lt; rows1 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols1 &lt;&lt; std::endl
<a name="l00334"></a>00334                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 2 dimensions:\t&quot;</span> &lt;&lt; rows2 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols2 &lt;&lt; std::endl;
<a name="l00335"></a>00335                 exit(1);
<a name="l00336"></a>00336                 }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows1, cols2);
<a name="l00339"></a>00339 
<a name="l00341"></a>00341         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; cols1; i++)
<a name="l00342"></a>00342                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols1; j++)
<a name="l00343"></a>00343                         result(i,j) = this-&gt;<a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,j) * matrix(i,j);
<a name="l00344"></a>00344 
<a name="l00345"></a>00345         <span class="keywordflow">return</span> result;
<a name="l00346"></a>00346         }
<a name="l00347"></a>00347 
<a name="l00348"></a>00348 <span class="preprocessor">#ifdef QVMATRIXALGEBRA_AVAILABLE</span>
<a name="l00349"></a><a class="code" href="classQVMatrix.html#a35e6590cf43e82694aa2b3d8e6559136">00349</a> <span class="preprocessor"></span><a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a35e6590cf43e82694aa2b3d8e6559136" title="Matrix-matrix division.">QVMatrix::matrixDivide</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00350"></a>00350 <span class="keyword">        </span>{
<a name="l00351"></a>00351         Q_ASSERT(matrix.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>() &gt;= matrix.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00352"></a>00352         Q_ASSERT(matrix.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>() == (*this).getCols());
<a name="l00353"></a>00353 
<a name="l00354"></a>00354         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(matrix.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), (*this).getRows());
<a name="l00355"></a>00355 
<a name="l00356"></a>00356         <span class="comment">//if (matrix.getCols() == matrix.getRows())</span>
<a name="l00357"></a>00357         <span class="comment">//      solveByLUDecomposition(matrix.transpose(), result, (*this).transpose());</span>
<a name="l00358"></a>00358         <span class="comment">//else</span>
<a name="l00359"></a>00359         <a class="code" href="group__qvmatrixalgebra.html#gac5e38c9a7f64b9c7785f4d353c0b9ada" title="Solves the linear system  for the unknown vector , using the singular value decomposition...">solveBySingularValueDecomposition</a>(matrix.<a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e" title="Change the order of the indexes in the matrix.">transpose</a>(), result, (*this).<a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e" title="Change the order of the indexes in the matrix.">transpose</a>());
<a name="l00360"></a>00360 
<a name="l00361"></a>00361         <span class="keywordflow">return</span> result.transpose();
<a name="l00362"></a>00362         }
<a name="l00363"></a>00363 
<a name="l00364"></a><a class="code" href="classQVMatrix.html#a051fa63dfff104d2705b793b4eb39213">00364</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#a051fa63dfff104d2705b793b4eb39213" title="Triangular system solving (vector of RHS).">QVMatrix::triangularSolve</a>(<span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;b, <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;x, <span class="keywordtype">bool</span> transposed, <span class="keywordtype">bool</span> unit_diagonal)<span class="keyword"> const</span>
<a name="l00365"></a>00365 <span class="keyword"></span>{
<a name="l00366"></a>00366     x = b;
<a name="l00367"></a>00367 
<a name="l00368"></a>00368 <span class="comment">//    enum CBLAS_UPLO Uplo = CblasUpper;</span>
<a name="l00369"></a>00369 
<a name="l00370"></a>00370     <span class="keywordflow">switch</span>(this-&gt;<a class="code" href="classQVMatrix.html#a546d28cd3b62456bb4e09987c9904162" title="Get type of the matrix.">getType</a>()) {
<a name="l00371"></a>00371         <span class="keywordflow">case</span> <a class="code" href="classQVMatrix.html#a8f4414e6cfd14fe164a164ab20379999a266e723ddafba230f9e674cb61c1a86d" title="Upper triangular matrix.">UpperTriangular</a>:
<a name="l00372"></a>00372 <span class="comment">//            Uplo = CblasUpper;</span>
<a name="l00373"></a>00373                 cblas_dtrsv(CblasRowMajor, CblasUpper,transposed?CblasTrans:CblasNoTrans,unit_diagonal?CblasUnit:CblasNonUnit,
<a name="l00374"></a>00374                         this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),x.data(),1);
<a name="l00375"></a>00375                 <span class="keywordflow">break</span>;
<a name="l00376"></a>00376         <span class="keywordflow">case</span> <a class="code" href="classQVMatrix.html#a8f4414e6cfd14fe164a164ab20379999ab550fa0060215d15361dfc059a2c19db" title="Lower triangular matrix.">LowerTriangular</a>:
<a name="l00377"></a>00377   <span class="comment">//          Uplo = CblasLower;</span>
<a name="l00378"></a>00378                 cblas_dtrsv(CblasRowMajor, CblasLower,transposed?CblasTrans:CblasNoTrans,unit_diagonal?CblasUnit:CblasNonUnit,
<a name="l00379"></a>00379                         this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),x.data(),1);
<a name="l00380"></a>00380                 <span class="keywordflow">break</span>;
<a name="l00381"></a>00381         <span class="keywordflow">default</span>:
<a name="l00382"></a>00382             qFatal(<span class="stringliteral">&quot;QVMatrix::triangularSolve() method called with non-triangular matrix\n&quot;</span>);            
<a name="l00383"></a>00383     }
<a name="l00384"></a>00384 
<a name="l00385"></a>00385     <span class="comment">/*cblas_dtrsv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const enum</span>
<a name="l00386"></a>00386 <span class="comment">    CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag, const int N,const double *A, const int</span>
<a name="l00387"></a>00387 <span class="comment">    lda, double *X, const int incX);*/</span>
<a name="l00388"></a>00388 
<a name="l00389"></a>00389 
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391 
<a name="l00392"></a><a class="code" href="classQVMatrix.html#af70ecaa97b938478d6e77dc05defcdda">00392</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#a051fa63dfff104d2705b793b4eb39213" title="Triangular system solving (vector of RHS).">QVMatrix::triangularSolve</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;B, <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;X, <span class="keywordtype">bool</span> transposed, <span class="keywordtype">bool</span> unit_diagonal, <span class="keywordtype">bool</span> left)<span class="keyword"> const</span>
<a name="l00393"></a>00393 <span class="keyword"></span>{
<a name="l00394"></a>00394     X = B;
<a name="l00395"></a>00395 
<a name="l00396"></a>00396 <span class="comment">//    enum CBLAS_UPLO Uplo = CblasUpper;</span>
<a name="l00397"></a>00397 
<a name="l00398"></a>00398     <span class="keywordflow">switch</span>(this-&gt;<a class="code" href="classQVMatrix.html#a546d28cd3b62456bb4e09987c9904162" title="Get type of the matrix.">getType</a>()) {
<a name="l00399"></a>00399         <span class="keywordflow">case</span> <a class="code" href="classQVMatrix.html#a8f4414e6cfd14fe164a164ab20379999a266e723ddafba230f9e674cb61c1a86d" title="Upper triangular matrix.">UpperTriangular</a>:
<a name="l00400"></a>00400   <span class="comment">//          Uplo = ;</span>
<a name="l00401"></a>00401             cblas_dtrsm(CblasRowMajor, left?CblasLeft:CblasRight, CblasUpper, transposed?CblasTrans:CblasNoTrans,
<a name="l00402"></a>00402                         unit_diagonal?CblasUnit:CblasNonUnit,
<a name="l00403"></a>00403                         this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),X.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(),1.0,this-&gt;<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),X.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>(),X.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00404"></a>00404             <span class="keywordflow">break</span>;
<a name="l00405"></a>00405         <span class="keywordflow">case</span> <a class="code" href="classQVMatrix.html#a8f4414e6cfd14fe164a164ab20379999ab550fa0060215d15361dfc059a2c19db" title="Lower triangular matrix.">LowerTriangular</a>:
<a name="l00406"></a>00406 <span class="comment">//            Uplo = ;</span>
<a name="l00407"></a>00407             cblas_dtrsm(CblasRowMajor, left?CblasLeft:CblasRight, CblasLower, transposed?CblasTrans:CblasNoTrans,
<a name="l00408"></a>00408                         unit_diagonal?CblasUnit:CblasNonUnit,
<a name="l00409"></a>00409                         this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),X.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(),1.0,this-&gt;<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(),this-&gt;<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(),X.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>(),X.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00410"></a>00410             <span class="keywordflow">break</span>;
<a name="l00411"></a>00411         <span class="keywordflow">default</span>:
<a name="l00412"></a>00412             qFatal(<span class="stringliteral">&quot;QVMatrix::triangularSolve() method called with non-triangular matrix\n&quot;</span>);
<a name="l00413"></a>00413     }
<a name="l00414"></a>00414 
<a name="l00415"></a>00415     <span class="comment">/*void cblas_dtrsm(const enum CBLAS_ORDER Order, const enum CBLAS_SIDE Side, const enum</span>
<a name="l00416"></a>00416 <span class="comment">    CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag, const int</span>
<a name="l00417"></a>00417 <span class="comment">    M, const int N, const double alpha, const double *A, const int lda, double *B, const int</span>
<a name="l00418"></a>00418 <span class="comment">    ldb);*/</span>
<a name="l00419"></a>00419 }
<a name="l00420"></a>00420 
<a name="l00421"></a><a class="code" href="classQVMatrix.html#ab00a021c82b223c25b6d51c203e30d16">00421</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ab00a021c82b223c25b6d51c203e30d16" title="Computes the inverse of the matrix.">QVMatrix::inverse</a>()<span class="keyword"> const</span>
<a name="l00422"></a>00422 <span class="keyword">        </span>{
<a name="l00424"></a>00424         <span class="keywordflow">return</span> <a class="code" href="group__qvmatrixalgebra.html#gadf6472ec782375d465ff1e87b3ae2557" title="Obtains the Moore–Penrose pseudoinverse of a matrix.">pseudoInverse</a>(*<span class="keyword">this</span>);
<a name="l00425"></a>00425         }
<a name="l00426"></a>00426 
<a name="l00427"></a><a class="code" href="classQVMatrix.html#a340dd57c9cd0130521af15af550cfef2">00427</a> <span class="keywordtype">double</span> <a class="code" href="classQVMatrix.html#a340dd57c9cd0130521af15af550cfef2" title="Computes the determinant of the matrix.">QVMatrix::det</a>()<span class="keyword"> const</span>
<a name="l00428"></a>00428 <span class="keyword">        </span>{
<a name="l00429"></a>00429         <span class="keywordflow">return</span> <a class="code" href="group__qvmatrixalgebra.html#ga18cb128a894fa599a42b85e403049416" title="Obtains the determinant of a square matrix.">determinant</a>(*<span class="keyword">this</span>);
<a name="l00430"></a>00430         }
<a name="l00431"></a>00431 <span class="preprocessor">#endif</span>
<a name="l00432"></a>00432 <span class="preprocessor"></span>
<a name="l00433"></a><a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e">00433</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a2f87710c9d8ae4b07b03605daea3782e" title="Change the order of the indexes in the matrix.">QVMatrix::transpose</a>()<span class="keyword"> const</span>
<a name="l00434"></a>00434 <span class="keyword">        </span>{
<a name="l00435"></a>00435         <span class="keyword">const</span> <span class="keywordtype">int</span> rows = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00436"></a>00436 
<a name="l00437"></a>00437         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(cols, rows);
<a name="l00438"></a>00438 
<a name="l00439"></a>00439         <span class="keyword">const</span> <span class="keywordtype">double</span>    *matrixData = <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00440"></a>00440         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00441"></a>00441 
<a name="l00443"></a>00443         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00444"></a>00444                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00445"></a>00445                         resultData[j*rows+i] = matrixData[i*cols+j];
<a name="l00446"></a>00446 
<a name="l00447"></a>00447         <span class="keywordflow">return</span> result;
<a name="l00448"></a>00448         }
<a name="l00449"></a>00449 
<a name="l00450"></a><a class="code" href="classQVMatrix.html#ae6b416b2be44685dab80600afd239ed4">00450</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#ae6b416b2be44685dab80600afd239ed4" title="Sets every element of the matrix to a given value.">QVMatrix::set</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value)
<a name="l00451"></a>00451         {
<a name="l00452"></a>00452         <span class="keywordtype">double</span>          *resultData = <a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00453"></a>00453         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00454"></a>00454 
<a name="l00456"></a>00456         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00457"></a>00457                 resultData[i] = value;
<a name="l00458"></a>00458         }
<a name="l00459"></a>00459 
<a name="l00460"></a><a class="code" href="classQVMatrix.html#abcbf2346a9cf0a62444d7a9254890952">00460</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#abcbf2346a9cf0a62444d7a9254890952" title="Matrix-matrix addition.">QVMatrix::addition</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00461"></a>00461 <span class="keyword">        </span>{
<a name="l00462"></a>00462         Q_ASSERT(cols == matrix.cols || rows == matrix.rows);
<a name="l00463"></a>00463 
<a name="l00464"></a>00464         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00465"></a>00465 
<a name="l00466"></a>00466         <span class="keyword">const</span> <span class="keywordtype">double</span>    *matrixData = matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00467"></a>00467         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00468"></a>00468         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = matrix.<a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00469"></a>00469 
<a name="l00471"></a>00471         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00472"></a>00472                 resultData[i] += matrixData[i];
<a name="l00473"></a>00473 
<a name="l00474"></a>00474         <span class="keywordflow">return</span> result;
<a name="l00475"></a>00475         }
<a name="l00476"></a>00476 
<a name="l00477"></a>00477 <span class="comment">// @todo use daxpy for inline addition.</span>
<a name="l00478"></a><a class="code" href="classQVMatrix.html#a383f8068c7fe6e793807e20542f779d1">00478</a> <span class="keywordtype">void</span>    <a class="code" href="classQVMatrix.html#a383f8068c7fe6e793807e20542f779d1" title="Matrix-matrix addition.">QVMatrix::inlineAddition</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l00479"></a>00479         {
<a name="l00480"></a>00480         Q_ASSERT(cols == matrix.cols || rows == matrix.rows);
<a name="l00481"></a>00481 
<a name="l00482"></a>00482         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00483"></a>00483 
<a name="l00484"></a>00484         <span class="keyword">const</span> <span class="keywordtype">double</span>    *matrixData = matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00485"></a>00485         <span class="keywordtype">double</span>          *resultData = <a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00486"></a>00486         <span class="keyword">const</span> <span class="keywordtype">int</span>               dataSize = matrix.<a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00487"></a>00487 
<a name="l00489"></a>00489         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00490"></a>00490                 resultData[i] += matrixData[i];
<a name="l00491"></a>00491         }
<a name="l00492"></a>00492 
<a name="l00493"></a><a class="code" href="classQVMatrix.html#ac65404c74ffc0f41f6d22a3fd6914f8a">00493</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ac65404c74ffc0f41f6d22a3fd6914f8a" title="Matrix-matrix substraction.">QVMatrix::substract</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00494"></a>00494 <span class="keyword">        </span>{
<a name="l00495"></a>00495         <span class="comment">// Check valences for both matrixs are equivalent</span>
<a name="l00496"></a>00496         Q_ASSERT(cols == matrix.cols || rows == matrix.rows);
<a name="l00497"></a>00497 
<a name="l00498"></a>00498         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00499"></a>00499 
<a name="l00500"></a>00500         <span class="keyword">const</span> <span class="keywordtype">double</span>    *matrixData = matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00501"></a>00501         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00502"></a>00502         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = matrix.<a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00503"></a>00503 
<a name="l00505"></a>00505 
<a name="l00506"></a>00506         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00507"></a>00507                 resultData[i] -= matrixData[i];
<a name="l00508"></a>00508 
<a name="l00509"></a>00509         <span class="keywordflow">return</span> result;
<a name="l00510"></a>00510         }
<a name="l00511"></a>00511 
<a name="l00512"></a><a class="code" href="classQVMatrix.html#a75ac95f4f6c88b4354e4e8aeab5b13a1">00512</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a75ac95f4f6c88b4354e4e8aeab5b13a1" title="Matrix-scalar product.">QVMatrix::scalarProduct</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value)<span class="keyword"> const</span>
<a name="l00513"></a>00513 <span class="keyword">        </span>{
<a name="l00514"></a>00514         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00515"></a>00515 
<a name="l00516"></a>00516         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00517"></a>00517         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00518"></a>00518 
<a name="l00520"></a>00520 
<a name="l00521"></a>00521         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00522"></a>00522                 resultData[i] *= value;
<a name="l00523"></a>00523 
<a name="l00524"></a>00524         <span class="keywordflow">return</span> result;
<a name="l00525"></a>00525         }
<a name="l00526"></a>00526 
<a name="l00527"></a><a class="code" href="classQVMatrix.html#ab87d29d63b8f41ff3f4a812a813f7718">00527</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ab87d29d63b8f41ff3f4a812a813f7718" title="Matrix-scalar division.">QVMatrix::scalarDivide</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value)<span class="keyword"> const</span>
<a name="l00528"></a>00528 <span class="keyword">        </span>{
<a name="l00529"></a>00529         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00530"></a>00530 
<a name="l00531"></a>00531         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00532"></a>00532         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00533"></a>00533 
<a name="l00535"></a>00535 
<a name="l00536"></a>00536         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00537"></a>00537                 resultData[i] /= value;
<a name="l00538"></a>00538 
<a name="l00539"></a>00539         <span class="keywordflow">return</span> result;
<a name="l00540"></a>00540         }
<a name="l00541"></a>00541 
<a name="l00542"></a><a class="code" href="classQVMatrix.html#af1286b0c208cec68dd42e5411b210081">00542</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#af1286b0c208cec68dd42e5411b210081" title="Matrix-scalar addition.">QVMatrix::scalarAdd</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value)<span class="keyword"> const</span>
<a name="l00543"></a>00543 <span class="keyword">        </span>{
<a name="l00544"></a>00544         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00545"></a>00545 
<a name="l00546"></a>00546         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00547"></a>00547         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00548"></a>00548 
<a name="l00550"></a>00550 
<a name="l00551"></a>00551         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00552"></a>00552                 resultData[i] += value;
<a name="l00553"></a>00553 
<a name="l00554"></a>00554         <span class="keywordflow">return</span> result;
<a name="l00555"></a>00555         }
<a name="l00556"></a>00556 
<a name="l00557"></a><a class="code" href="classQVMatrix.html#a6980327fe32d68ae6028482a8a96200e">00557</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a6980327fe32d68ae6028482a8a96200e" title="Matrix-scalar substraction.">QVMatrix::scalarSubstract</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value)<span class="keyword"> const</span>
<a name="l00558"></a>00558 <span class="keyword">        </span>{
<a name="l00559"></a>00559         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = *<span class="keyword">this</span>;
<a name="l00560"></a>00560 
<a name="l00561"></a>00561         <span class="keywordtype">double</span>          *resultData = result.<a class="code" href="classQVMatrix.html#a0c5b1e685d14d230c55cfcfb058e372a" title="Gets a reference of the data buffer of the matrix for read and write accesses.">getWriteData</a>();
<a name="l00562"></a>00562         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00563"></a>00563 
<a name="l00565"></a>00565 
<a name="l00566"></a>00566         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00567"></a>00567                 resultData[i] -= value;
<a name="l00568"></a>00568 
<a name="l00569"></a>00569         <span class="keywordflow">return</span> result;
<a name="l00570"></a>00570         }
<a name="l00571"></a>00571 
<a name="l00572"></a><a class="code" href="classQVMatrix.html#a7b51282594521a3a7c759c7a43b5e73a">00572</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a7b51282594521a3a7c759c7a43b5e73a" title="Appends matrices horizontally.">QVMatrix::horizontalAppend</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00573"></a>00573 <span class="keyword">        </span>{
<a name="l00574"></a>00574         <span class="keyword">const</span> <span class="keywordtype">int</span> cols1 = cols, rows1 = rows, cols2 = matrix.cols, rows2 = matrix.rows;
<a name="l00575"></a>00575 
<a name="l00576"></a>00576         Q_ASSERT(rows1 == rows2);
<a name="l00577"></a>00577 
<a name="l00578"></a>00578         <span class="keywordflow">if</span> (rows1 != rows2)
<a name="l00579"></a>00579                 {
<a name="l00580"></a>00580                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to append horizontally matrices with different row number at QVMatrix::horizontalAppend(const QVMatrix &amp;matrix).&quot;</span>
<a name="l00581"></a>00581                         &lt;&lt; std::endl
<a name="l00582"></a>00582                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 1 dimensions:\t&quot;</span> &lt;&lt; rows1 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols1 &lt;&lt; std::endl
<a name="l00583"></a>00583                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 2 dimensions:\t&quot;</span> &lt;&lt; rows2 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols2 &lt;&lt; std::endl;
<a name="l00584"></a>00584                 exit(1);
<a name="l00585"></a>00585                 }
<a name="l00586"></a>00586 
<a name="l00587"></a>00587         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows1, cols1 + cols2);
<a name="l00588"></a>00588 
<a name="l00589"></a>00589         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; cols1; i++)
<a name="l00590"></a>00590                 result.<a class="code" href="classQVMatrix.html#a8ebc03603ced1c727afd6f3bd755e57a" title="Sets a column of the matrix.">setCol</a>(i, <a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa" title="Gets a column of the matrix.">getCol</a>(i));
<a name="l00591"></a>00591 
<a name="l00592"></a>00592         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; cols2; i++)
<a name="l00593"></a>00593                 result.<a class="code" href="classQVMatrix.html#a8ebc03603ced1c727afd6f3bd755e57a" title="Sets a column of the matrix.">setCol</a>(cols1 + i, matrix.<a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa" title="Gets a column of the matrix.">getCol</a>(i));
<a name="l00594"></a>00594 
<a name="l00595"></a>00595         <span class="keywordflow">return</span> result;
<a name="l00596"></a>00596         }
<a name="l00597"></a>00597 
<a name="l00598"></a><a class="code" href="classQVMatrix.html#aec43856676ac83417fcafda9d4ef57e5">00598</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#aec43856676ac83417fcafda9d4ef57e5" title="Appends matrices vertically.">QVMatrix::verticalAppend</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)<span class="keyword"> const</span>
<a name="l00599"></a>00599 <span class="keyword">        </span>{
<a name="l00600"></a>00600         <span class="keyword">const</span> <span class="keywordtype">int</span> cols1 = cols, rows1 = rows, cols2 = matrix.cols, rows2 = matrix.rows;
<a name="l00601"></a>00601 
<a name="l00602"></a>00602         Q_ASSERT(cols1 == cols2);
<a name="l00603"></a>00603 
<a name="l00604"></a>00604         <span class="keywordflow">if</span> (cols1 != cols2)
<a name="l00605"></a>00605                 {
<a name="l00606"></a>00606                 std::cout &lt;&lt; <span class="stringliteral">&quot;ERROR: tried to append vertically matrices with different row number at QVMatrix::horizontalAppend(const QVMatrix &amp;matrix).&quot;</span>
<a name="l00607"></a>00607                         &lt;&lt; std::endl
<a name="l00608"></a>00608                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 1 dimensions:\t&quot;</span> &lt;&lt; rows1 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols1 &lt;&lt; std::endl
<a name="l00609"></a>00609                         &lt;&lt; <span class="stringliteral">&quot;\tMatrix 2 dimensions:\t&quot;</span> &lt;&lt; rows2 &lt;&lt; <span class="stringliteral">&quot;x&quot;</span> &lt;&lt; cols2 &lt;&lt; std::endl;
<a name="l00610"></a>00610                 exit(1);
<a name="l00611"></a>00611                 }
<a name="l00612"></a>00612 
<a name="l00613"></a>00613         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows1 + rows2, cols2);
<a name="l00614"></a>00614 
<a name="l00615"></a>00615         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows1; i++)
<a name="l00616"></a>00616                 result.<a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(i, <a class="code" href="classQVMatrix.html#ae27f08cd9a56a5c85ba2757cc4078d80" title="Gets a row of the matrix.">getRow</a>(i));
<a name="l00617"></a>00617 
<a name="l00618"></a>00618         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows2; i++)
<a name="l00619"></a>00619                 result.<a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(rows1 + i, matrix.<a class="code" href="classQVMatrix.html#ae27f08cd9a56a5c85ba2757cc4078d80" title="Gets a row of the matrix.">getRow</a>(i));
<a name="l00620"></a>00620 
<a name="l00621"></a>00621         <span class="keywordflow">return</span> result;
<a name="l00622"></a>00622         }
<a name="l00623"></a>00623 
<a name="l00625"></a>00625 
<a name="l00626"></a><a class="code" href="classQVMatrix.html#a387750529622104faba8047cb0efa62a">00626</a> <span class="keywordtype">double</span> <a class="code" href="classQVMatrix.html#a387750529622104faba8047cb0efa62a" title="Gets the norm2 for matrix.">QVMatrix::norm2</a>()<span class="keyword"> const</span>
<a name="l00627"></a>00627 <span class="keyword">        </span>{
<a name="l00628"></a>00628 <span class="preprocessor">        #ifdef BLAS_AVAILABLE</span>
<a name="l00629"></a>00629 <span class="preprocessor"></span>        <span class="keywordflow">return</span> cblas_dnrm2(<a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>(), <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>(), 1);
<a name="l00630"></a>00630 <span class="preprocessor">        #else</span>
<a name="l00631"></a>00631 <span class="preprocessor"></span>        std::cout &lt;&lt; <span class="stringliteral">&quot;[QVMatrix::dotProduct] --------------------------------- Not blas! --------------------&quot;</span> &lt;&lt; std::endl;
<a name="l00632"></a>00632         <span class="keywordtype">double</span> accum = 0.0;
<a name="l00633"></a>00633         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), rows = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>();
<a name="l00634"></a>00634 
<a name="l00635"></a>00635         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00636"></a>00636                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00637"></a>00637                         {
<a name="l00638"></a>00638                         <span class="keyword">const</span> <span class="keywordtype">double</span> actualValue = <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,j);
<a name="l00639"></a>00639                         accum += actualValue * actualValue;
<a name="l00640"></a>00640                         }
<a name="l00641"></a>00641         <span class="keywordflow">return</span> sqrt(accum);
<a name="l00642"></a>00642 <span class="preprocessor">        #endif</span>
<a name="l00643"></a>00643 <span class="preprocessor"></span>        };
<a name="l00644"></a>00644 
<a name="l00645"></a><a class="code" href="classQVMatrix.html#a9e57c222b6e0b0d8f43576b8ffc01e04">00645</a> <span class="keywordtype">double</span> <a class="code" href="classQVMatrix.html#a9e57c222b6e0b0d8f43576b8ffc01e04" title="Gets the trace of the matrix.">QVMatrix::trace</a>()<span class="keyword"> const</span>
<a name="l00646"></a>00646 <span class="keyword">        </span>{
<a name="l00647"></a>00647         <span class="keyword">const</span> <span class="keywordtype">int</span> n = MIN(<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00648"></a>00648         <span class="keywordtype">double</span> accum = 0.0;
<a name="l00649"></a>00649         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; n; i++)
<a name="l00650"></a>00650                 accum += <span class="keyword">operator</span>()(i,i);
<a name="l00651"></a>00651         <span class="keywordflow">return</span> accum;
<a name="l00652"></a>00652         }
<a name="l00653"></a>00653 
<a name="l00654"></a><a class="code" href="classQVMatrix.html#aaaf9670f3170fdb0f609d6d08a75a05d">00654</a> <span class="keywordtype">bool</span> <a class="code" href="classQVMatrix.html#aaaf9670f3170fdb0f609d6d08a75a05d" title="Checks whether the matrix is a diagonal matrix or not.">QVMatrix::isDiagonal</a>()<span class="keyword"> const</span>
<a name="l00655"></a>00655 <span class="keyword">        </span>{
<a name="l00656"></a>00656         <span class="keyword">const</span> <span class="keywordtype">double</span>    *data = <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00657"></a>00657         <span class="comment">//const int             dataSize = getDataSize();</span>
<a name="l00658"></a>00658 
<a name="l00659"></a>00659         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00660"></a>00660                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00661"></a>00661                         <span class="keywordflow">if</span> ( (i != j) and (data[i*cols+j] != 0.0) )
<a name="l00662"></a>00662                                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00663"></a>00663 
<a name="l00664"></a>00664         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00665"></a>00665         }
<a name="l00666"></a>00666 
<a name="l00667"></a><a class="code" href="classQVMatrix.html#a43455dfaf2e8fa71242ea1fdc8beb102">00667</a> <span class="keywordtype">bool</span> <a class="code" href="classQVMatrix.html#a43455dfaf2e8fa71242ea1fdc8beb102" title="Checks whether the matrix contains a NaN value or not.">QVMatrix::containsNaN</a>()<span class="keyword"> const</span>
<a name="l00668"></a>00668 <span class="keyword">        </span>{
<a name="l00669"></a>00669         <span class="keyword">const</span> <span class="keywordtype">double</span>    *data = <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00670"></a>00670         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00671"></a>00671 
<a name="l00672"></a>00672         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00673"></a>00673                 <span class="keywordflow">if</span> (isnan(data[i]))
<a name="l00674"></a>00674                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00675"></a>00675 
<a name="l00676"></a>00676         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00677"></a>00677         }
<a name="l00678"></a>00678 
<a name="l00679"></a><a class="code" href="classQVMatrix.html#a6172be84a1ff456c4f39b37e6e3d3eaa">00679</a> <span class="keywordtype">bool</span> <a class="code" href="classQVMatrix.html#a6172be84a1ff456c4f39b37e6e3d3eaa" title="Checks whether the matrix contains an infinite value or not.">QVMatrix::containsInf</a>()<span class="keyword"> const</span>
<a name="l00680"></a>00680 <span class="keyword">        </span>{
<a name="l00681"></a>00681         <span class="keyword">const</span> <span class="keywordtype">double</span>    *data = <a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00682"></a>00682         <span class="keyword">const</span> <span class="keywordtype">int</span>       dataSize = <a class="code" href="classQVMatrix.html#ae9de904f46a790bef981c0101a4ee6f6" title="Gets the size of the data array.">getDataSize</a>();
<a name="l00683"></a>00683 
<a name="l00684"></a>00684         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; dataSize; i++)
<a name="l00685"></a>00685                 <span class="keywordflow">if</span> (isinf(data[i]))
<a name="l00686"></a>00686                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00687"></a>00687 
<a name="l00688"></a>00688         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00689"></a>00689         }
<a name="l00690"></a>00690 
<a name="l00691"></a><a class="code" href="classQVMatrix.html#a12aec43704cd3577bea5fd127343aee0">00691</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a12aec43704cd3577bea5fd127343aee0" title="Homogeneous normalization for rows of the matrix.">QVMatrix::rowHomogeneousNormalize</a>()<span class="keyword"> const</span>
<a name="l00692"></a>00692 <span class="keyword">        </span>{
<a name="l00693"></a>00693         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), rows = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>();
<a name="l00694"></a>00694         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows, cols);
<a name="l00695"></a>00695 
<a name="l00696"></a>00696         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l00697"></a>00697                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00698"></a>00698                         result(i,j) = <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,j) / <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,cols-1);
<a name="l00699"></a>00699         <span class="keywordflow">return</span> result;
<a name="l00700"></a>00700         }
<a name="l00701"></a>00701 
<a name="l00702"></a><a class="code" href="classQVMatrix.html#ae27f08cd9a56a5c85ba2757cc4078d80">00702</a> <span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#ae27f08cd9a56a5c85ba2757cc4078d80" title="Gets a row of the matrix.">QVMatrix::getRow</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> row)<span class="keyword"> const</span>
<a name="l00703"></a>00703 <span class="keyword">        </span>{
<a name="l00704"></a>00704         Q_ASSERT(row &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00705"></a>00705 
<a name="l00706"></a>00706         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00707"></a>00707         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result(cols);
<a name="l00708"></a>00708         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> col= 0; col &lt; cols; col++)
<a name="l00709"></a>00709                 result[col] = <span class="keyword">operator</span>()(row,col);
<a name="l00710"></a>00710 
<a name="l00711"></a>00711         <span class="keywordflow">return</span> result;
<a name="l00712"></a>00712         }
<a name="l00713"></a>00713 
<a name="l00714"></a><a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8">00714</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">QVMatrix::setRow</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> row, <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> vector)
<a name="l00715"></a>00715         {
<a name="l00716"></a>00716         Q_ASSERT(row &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00717"></a>00717         Q_ASSERT(<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>() == vector.size());
<a name="l00718"></a>00718 
<a name="l00719"></a>00719         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00720"></a>00720         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> col= 0; col &lt; cols; col++)
<a name="l00721"></a>00721                 <span class="keyword">operator</span>()(row,col) = vector[col];
<a name="l00722"></a>00722         }
<a name="l00723"></a>00723 
<a name="l00724"></a><a class="code" href="classQVMatrix.html#a002135a00c7da0bce059a47bc1def347">00724</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">QVMatrix::setRow</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> row, QVector&lt;double&gt; vector)
<a name="l00725"></a>00725         {
<a name="l00726"></a>00726         Q_ASSERT(row &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00727"></a>00727         Q_ASSERT(<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>() == vector.size());
<a name="l00728"></a>00728 
<a name="l00729"></a>00729         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00730"></a>00730         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> col= 0; col &lt; cols; col++)
<a name="l00731"></a>00731                 <span class="keyword">operator</span>()(row,col) = vector[col];
<a name="l00732"></a>00732         }
<a name="l00733"></a>00733 
<a name="l00734"></a><a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa">00734</a> <span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa" title="Gets a column of the matrix.">QVMatrix::getCol</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> col)<span class="keyword"> const</span>
<a name="l00735"></a>00735 <span class="keyword">        </span>{
<a name="l00736"></a>00736         Q_ASSERT(col &lt; <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00737"></a>00737 
<a name="l00738"></a>00738         <span class="keyword">const</span> <span class="keywordtype">int</span> rows = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>();
<a name="l00739"></a>00739         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result(rows);
<a name="l00740"></a>00740         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> row= 0; row &lt; rows; row++)
<a name="l00741"></a>00741                 result[row] = <span class="keyword">operator</span>()(row,col);
<a name="l00742"></a>00742 
<a name="l00743"></a>00743         <span class="keywordflow">return</span> result;
<a name="l00744"></a>00744         }
<a name="l00745"></a>00745 
<a name="l00746"></a><a class="code" href="classQVMatrix.html#a8ebc03603ced1c727afd6f3bd755e57a">00746</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#a8ebc03603ced1c727afd6f3bd755e57a" title="Sets a column of the matrix.">QVMatrix::setCol</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> col, <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> vector)
<a name="l00747"></a>00747         {
<a name="l00748"></a>00748         Q_ASSERT(col &lt; <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00749"></a>00749         Q_ASSERT(<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>() == vector.size());
<a name="l00750"></a>00750 
<a name="l00751"></a>00751         <span class="keyword">const</span> <span class="keywordtype">int</span> rows = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>();
<a name="l00752"></a>00752         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> row= 0; row &lt; rows; row++)
<a name="l00753"></a>00753                 <span class="keyword">operator</span>()(row,col) = vector[row];
<a name="l00754"></a>00754         }
<a name="l00755"></a>00755 
<a name="l00756"></a>00756 
<a name="l00757"></a><a class="code" href="classQVMatrix.html#abcfe032545b49448a2a064a7952f7ece">00757</a> <span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#abcfe032545b49448a2a064a7952f7ece" title="Gets the diagonal of the matrix.">QVMatrix::diagonal</a>()<span class="keyword"> const</span>
<a name="l00758"></a>00758 <span class="keyword">        </span>{
<a name="l00759"></a>00759         Q_ASSERT(<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>() == <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00760"></a>00760         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result(<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00761"></a>00761         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(); i++)
<a name="l00762"></a>00762                 result[i] = <span class="keyword">operator</span>()(i,i);
<a name="l00763"></a>00763 
<a name="l00764"></a>00764         <span class="keywordflow">return</span> result;
<a name="l00765"></a>00765         }
<a name="l00766"></a>00766 
<a name="l00768"></a><a class="code" href="classQVMatrix.html#a77b34335086bb9e12d7d72398c608e75">00768</a> <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a77b34335086bb9e12d7d72398c608e75" title="Gets a submatrix from a matrix.">QVMatrix::getSubmatrix</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> firstRow, <span class="keyword">const</span> <span class="keywordtype">int</span> lastRow, <span class="keyword">const</span> <span class="keywordtype">int</span> firstCol, <span class="keyword">const</span> <span class="keywordtype">int</span> lastCol)<span class="keyword"> const</span>
<a name="l00769"></a>00769 <span class="keyword">        </span>{
<a name="l00770"></a>00770         Q_ASSERT(firstRow &gt;= 0);
<a name="l00771"></a>00771         Q_ASSERT(firstCol &gt;= 0);
<a name="l00772"></a>00772         Q_ASSERT(firstRow &lt;= lastRow);
<a name="l00773"></a>00773         Q_ASSERT(firstCol &lt;= lastCol);
<a name="l00774"></a>00774         Q_ASSERT(lastRow &lt; <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00775"></a>00775         Q_ASSERT(lastCol &lt; <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00776"></a>00776 
<a name="l00777"></a>00777         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(lastRow - firstRow +1, lastCol - firstCol +1);
<a name="l00778"></a>00778 
<a name="l00779"></a>00779         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> row = firstRow; row &lt;= lastRow; row++)
<a name="l00780"></a>00780                 result.<a class="code" href="classQVMatrix.html#ad8684520b5095fb350022fc9acb0dba8" title="Sets a row of the matrix.">setRow</a>(row-firstRow, <a class="code" href="classQVMatrix.html#ae27f08cd9a56a5c85ba2757cc4078d80" title="Gets a row of the matrix.">getRow</a>(row).mid(firstCol, lastCol - firstCol +1));
<a name="l00781"></a>00781 
<a name="l00782"></a>00782         <span class="keywordflow">return</span> result;
<a name="l00783"></a>00783         }
<a name="l00784"></a>00784 
<a name="l00785"></a><a class="code" href="classQVMatrix.html#ac5ce9ed25c533d7b89abe5b6a5c6df3e">00785</a> <span class="keywordtype">void</span> <a class="code" href="classQVMatrix.html#ac5ce9ed25c533d7b89abe5b6a5c6df3e" title="Sets a submatrix from a matrix.">QVMatrix::setSubmatrix</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> row, <span class="keyword">const</span> <span class="keywordtype">int</span> col, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;M)
<a name="l00786"></a>00786         {
<a name="l00787"></a>00787         Q_ASSERT(col &gt;= 0);
<a name="l00788"></a>00788         Q_ASSERT(row &gt;= 0);
<a name="l00789"></a>00789         Q_ASSERT(M.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>() + col &lt;= <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>());
<a name="l00790"></a>00790         Q_ASSERT(M.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>() + row &lt;= <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>());
<a name="l00791"></a>00791 
<a name="l00792"></a>00792         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> r = 0; r &lt; M.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(); r++)
<a name="l00793"></a>00793                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c &lt; M.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(); c++)
<a name="l00794"></a>00794                         <span class="keyword">operator</span>()(r + row, c + col) = M(r, c);
<a name="l00795"></a>00795         }
<a name="l00796"></a>00796 
<a name="l00797"></a><a class="code" href="classQVMatrix.html#a8c360feaaf1382f1afeae554ca1af5b7">00797</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a8c360feaaf1382f1afeae554ca1af5b7" title="Gets a matrix with reversed rows (bottom to top).">QVMatrix::reversedRows</a>()<span class="keyword"> const</span>
<a name="l00798"></a>00798 <span class="keyword"></span>{
<a name="l00799"></a>00799     <span class="keywordtype">int</span> m = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), n = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00800"></a>00800     <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(m,n);
<a name="l00801"></a>00801 
<a name="l00802"></a>00802     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;m;i++)
<a name="l00803"></a>00803         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0;j&lt;n;j++)
<a name="l00804"></a>00804             result(i,j) = <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(m-1-i,j);
<a name="l00805"></a>00805 
<a name="l00806"></a>00806     <span class="keywordflow">return</span> result;
<a name="l00807"></a>00807 }
<a name="l00808"></a>00808 
<a name="l00809"></a><a class="code" href="classQVMatrix.html#a9987d3595383ca057eeaad815845f00a">00809</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a9987d3595383ca057eeaad815845f00a" title="Gets a matrix with reversed columns (right to left).">QVMatrix::reversedCols</a>()<span class="keyword"> const</span>
<a name="l00810"></a>00810 <span class="keyword"></span>{
<a name="l00811"></a>00811     <span class="keywordtype">int</span> m = <a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), n = <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00812"></a>00812     <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(m,n);
<a name="l00813"></a>00813 
<a name="l00814"></a>00814     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;m;i++)
<a name="l00815"></a>00815         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0;j&lt;n;j++)
<a name="l00816"></a>00816             result(i,j) = <a class="code" href="classQVMatrix.html#a7c4636a7c04ddacddb1cea2cbc1a5b60" title="Element access operator.">operator()</a>(i,n-1-j);
<a name="l00817"></a>00817 
<a name="l00818"></a>00818     <span class="keywordflow">return</span> result;
<a name="l00819"></a>00819 }
<a name="l00820"></a>00820 
<a name="l00822"></a>00822 <span class="comment">// Misc matrices</span>
<a name="l00823"></a>00823 
<a name="l00824"></a><a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715">00824</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">QVMatrix::identity</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> size)
<a name="l00825"></a>00825         {
<a name="l00826"></a>00826         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(size, size);
<a name="l00827"></a>00827         result.<a class="code" href="classQVMatrix.html#ae6b416b2be44685dab80600afd239ed4" title="Sets every element of the matrix to a given value.">set</a>(0);
<a name="l00828"></a>00828         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i= 0; i &lt; size; i++)
<a name="l00829"></a>00829                 result(i,i) = 1;
<a name="l00830"></a>00830         <span class="keywordflow">return</span> result;
<a name="l00831"></a>00831         }
<a name="l00832"></a>00832 
<a name="l00833"></a><a class="code" href="classQVMatrix.html#a953207e797ad5c2f8477d3507dbcf86b">00833</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a953207e797ad5c2f8477d3507dbcf86b" title="Creates an intrinsic camera calibration matrix.">QVMatrix::cameraCalibrationMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> focal, <span class="keyword">const</span> <span class="keywordtype">double</span> aspectRatio, <span class="keyword">const</span> <span class="keywordtype">double</span> cx, <span class="keyword">const</span> <span class="keywordtype">double</span> cy, <span class="keyword">const</span> <span class="keywordtype">double</span> skew)
<a name="l00834"></a>00834         {
<a name="l00835"></a>00835         <span class="keyword">const</span> <span class="keywordtype">double</span> dataK[9] = { focal, skew, cx, 0.0, aspectRatio*focal, cy, 0.0, 0.0, 1.0 };
<a name="l00836"></a>00836         <span class="keywordflow">return</span> <a class="code" href="classQVMatrix.html#ab4f574a0822e8d707ca40970563338a3" title="Default constructor.">QVMatrix</a>(3,3, dataK);
<a name="l00837"></a>00837         }
<a name="l00838"></a>00838 
<a name="l00839"></a><a class="code" href="classQVMatrix.html#aa51c7a1ffb2ec8c9f56cd4c10ad61e81">00839</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#aa51c7a1ffb2ec8c9f56cd4c10ad61e81" title="Creates a zero matrix.">QVMatrix::zeros</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> rows, <span class="keyword">const</span> <span class="keywordtype">int</span> cols)
<a name="l00840"></a>00840         {
<a name="l00841"></a>00841         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows, cols);
<a name="l00842"></a>00842         result.<a class="code" href="classQVMatrix.html#ae6b416b2be44685dab80600afd239ed4" title="Sets every element of the matrix to a given value.">set</a>(0);
<a name="l00843"></a>00843         <span class="keywordflow">return</span> result;
<a name="l00844"></a>00844         }
<a name="l00845"></a>00845 
<a name="l00846"></a><a class="code" href="classQVMatrix.html#ad2840553c7fa2cf81c8ce982db34b7b4">00846</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ad2840553c7fa2cf81c8ce982db34b7b4" title="Creates a matrix of random values.">QVMatrix::random</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> rows, <span class="keyword">const</span> <span class="keywordtype">int</span> cols)
<a name="l00847"></a>00847         {
<a name="l00848"></a>00848         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(rows, cols);
<a name="l00849"></a>00849         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> col = 0; col &lt; cols; col++)
<a name="l00850"></a>00850                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> row = 0; row &lt; rows; row++)
<a name="l00851"></a>00851                         result(row,col) = (double)ABS(rand()) / (<span class="keywordtype">double</span>)RAND_MAX;
<a name="l00852"></a>00852         <span class="keywordflow">return</span> result;
<a name="l00853"></a>00853         }
<a name="l00854"></a>00854 
<a name="l00855"></a><a class="code" href="classQVMatrix.html#a80d992c0c32f62f03d4d6d94a02cfed9">00855</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#abcfe032545b49448a2a064a7952f7ece" title="Gets the diagonal of the matrix.">QVMatrix::diagonal</a>(<span class="keyword">const</span> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> &amp;diagonalVector)
<a name="l00856"></a>00856         {
<a name="l00857"></a>00857         <span class="keyword">const</span> <span class="keywordtype">int</span> size = diagonalVector.size();
<a name="l00858"></a>00858         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(size, size);
<a name="l00859"></a>00859         result.<a class="code" href="classQVMatrix.html#ae6b416b2be44685dab80600afd239ed4" title="Sets every element of the matrix to a given value.">set</a>(0);
<a name="l00860"></a>00860         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i= 0; i &lt; size; i++)
<a name="l00861"></a>00861                 result(i,i) = diagonalVector[i];
<a name="l00862"></a>00862         <span class="keywordflow">return</span> result;
<a name="l00863"></a>00863         }
<a name="l00864"></a>00864 
<a name="l00865"></a><a class="code" href="classQVMatrix.html#a34cc7d7a575e6e8f766d5e8d6f71ec70">00865</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a34cc7d7a575e6e8f766d5e8d6f71ec70" title="Create a rotation matrix for points in the 2D plane.">QVMatrix::rotationMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> delta)
<a name="l00866"></a>00866         {
<a name="l00867"></a>00867         <span class="comment">// Rotation[delta_] := {{Cos[delta], Sin[delta], 0}, {-Sin[delta], Cos[delta], 0}, {0, 0, 1}};</span>
<a name="l00868"></a>00868         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">QVMatrix::identity</a>(3);
<a name="l00869"></a>00869 
<a name="l00870"></a>00870         result(0,0) = cos(delta);       result(0,1) = sin(delta);
<a name="l00871"></a>00871         result(1,0) = -sin(delta);      result(1,1) = cos(delta);
<a name="l00872"></a>00872 
<a name="l00873"></a>00873         <span class="keywordflow">return</span> result;
<a name="l00874"></a>00874         }
<a name="l00875"></a>00875 
<a name="l00876"></a><a class="code" href="classQVMatrix.html#a5ee1de2599284bf68e1940248487687c">00876</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a34cc7d7a575e6e8f766d5e8d6f71ec70" title="Create a rotation matrix for points in the 2D plane.">QVMatrix::rotationMatrix</a>(<span class="keyword">const</span> QPointF center, <span class="keyword">const</span> <span class="keywordtype">double</span> angle)
<a name="l00877"></a>00877         {
<a name="l00878"></a>00878         <span class="keywordflow">return</span> <a class="code" href="classQVMatrix.html#a0d4484ab18803104864a5da5a12e3231" title="Create a 2D translation matrix.">QVMatrix::translationMatrix</a>(center.x(), center.y()) * <a class="code" href="classQVMatrix.html#a34cc7d7a575e6e8f766d5e8d6f71ec70" title="Create a rotation matrix for points in the 2D plane.">QVMatrix::rotationMatrix</a>(angle) *
<a name="l00879"></a>00879                 <a class="code" href="classQVMatrix.html#a0d4484ab18803104864a5da5a12e3231" title="Create a 2D translation matrix.">QVMatrix::translationMatrix</a>(-center.x(), -center.y());
<a name="l00880"></a>00880         }
<a name="l00881"></a>00881 
<a name="l00882"></a><a class="code" href="classQVMatrix.html#a0d4484ab18803104864a5da5a12e3231">00882</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a0d4484ab18803104864a5da5a12e3231" title="Create a 2D translation matrix.">QVMatrix::translationMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> x, <span class="keyword">const</span> <span class="keywordtype">double</span> y)
<a name="l00883"></a>00883         <span class="comment">// Translation[x_, y_] := {{1, 0, x}, {0, 1, y}, {0, 0, 1}};</span>
<a name="l00884"></a>00884         {
<a name="l00885"></a>00885         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">QVMatrix::identity</a>(3);
<a name="l00886"></a>00886 
<a name="l00887"></a>00887         result(0,2) = x;
<a name="l00888"></a>00888         result(1,2) = y;
<a name="l00889"></a>00889 
<a name="l00890"></a>00890         <span class="keywordflow">return</span> result;
<a name="l00891"></a>00891         }
<a name="l00892"></a>00892 
<a name="l00893"></a><a class="code" href="classQVMatrix.html#ae85e5758081def4123365e2b949e8028">00893</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ae85e5758081def4123365e2b949e8028" title="Create a 2D scale matrix.">QVMatrix::scaleMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> zoom)
<a name="l00894"></a>00894         {
<a name="l00895"></a>00895         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">QVMatrix::identity</a>(3);
<a name="l00896"></a>00896 
<a name="l00897"></a>00897         result(0,0) = zoom;
<a name="l00898"></a>00898         result(1,1) = zoom;
<a name="l00899"></a>00899 
<a name="l00900"></a>00900         <span class="keywordflow">return</span> result;
<a name="l00901"></a>00901         }
<a name="l00902"></a>00902 
<a name="l00903"></a><a class="code" href="classQVMatrix.html#afceda9ac099f725f7c44d47a4e7e9a9f">00903</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#afceda9ac099f725f7c44d47a4e7e9a9f" title="Create a rotation matrix for 3D-Z axis.">QVMatrix::rotationMatrix3dZAxis</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> angle)
<a name="l00904"></a>00904         {
<a name="l00905"></a>00905         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">identity</a>(4);
<a name="l00906"></a>00906 
<a name="l00907"></a>00907         result(0,0) = cos(angle);
<a name="l00908"></a>00908         result(0,1) = sin(angle);
<a name="l00909"></a>00909 
<a name="l00910"></a>00910         result(1,0) = -sin(angle);
<a name="l00911"></a>00911         result(1,1) = cos(angle);
<a name="l00912"></a>00912 
<a name="l00913"></a>00913         <span class="keywordflow">return</span> result;
<a name="l00914"></a>00914         }
<a name="l00915"></a>00915 
<a name="l00916"></a><a class="code" href="classQVMatrix.html#a5b07abcac226018daecf7ed1251c79f4">00916</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#a5b07abcac226018daecf7ed1251c79f4" title="Create a rotation matrix for 3D-X axis.">QVMatrix::rotationMatrix3dXAxis</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> angle)
<a name="l00917"></a>00917         {
<a name="l00918"></a>00918         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">identity</a>(4);
<a name="l00919"></a>00919 
<a name="l00920"></a>00920         result(1,1) = cos(angle);
<a name="l00921"></a>00921         result(1,2) = sin(angle);
<a name="l00922"></a>00922 
<a name="l00923"></a>00923         result(2,1) = -sin(angle);
<a name="l00924"></a>00924         result(2,2) = cos(angle);
<a name="l00925"></a>00925 
<a name="l00926"></a>00926         <span class="keywordflow">return</span> result;
<a name="l00927"></a>00927         }
<a name="l00928"></a>00928 
<a name="l00929"></a><a class="code" href="classQVMatrix.html#ac78ee1008505af7a88f864c74d14c454">00929</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#ac78ee1008505af7a88f864c74d14c454" title="Create a rotation matrix for 3D-Y axis.">QVMatrix::rotationMatrix3dYAxis</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> angle)
<a name="l00930"></a>00930         {
<a name="l00931"></a>00931         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">identity</a>(4);
<a name="l00932"></a>00932 
<a name="l00933"></a>00933         result(0,0) = cos(angle);
<a name="l00934"></a>00934         result(0,2) = -sin(angle);
<a name="l00935"></a>00935 
<a name="l00936"></a>00936         result(2,0) = sin(angle);
<a name="l00937"></a>00937         result(2,2) = cos(angle);
<a name="l00938"></a>00938 
<a name="l00939"></a>00939         <span class="keywordflow">return</span> result;
<a name="l00940"></a>00940         }
<a name="l00941"></a>00941 
<a name="l00942"></a><a class="code" href="classQVMatrix.html#adcd15d700257dffdbf44cd015809dff0">00942</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="classQVMatrix.html#adcd15d700257dffdbf44cd015809dff0" title="Create a 3D translation matrix.">QVMatrix::translationMatrix3d</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> x, <span class="keyword">const</span> <span class="keywordtype">double</span> y, <span class="keyword">const</span> <span class="keywordtype">double</span> z)
<a name="l00943"></a>00943         {
<a name="l00944"></a>00944         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result = <a class="code" href="classQVMatrix.html#a6eb15980d17c17d4a55ab09a77bcd715" title="Creates an identity matrix.">identity</a>(4);
<a name="l00945"></a>00945 
<a name="l00946"></a>00946         result(0,3) = x;
<a name="l00947"></a>00947         result(1,3) = y;
<a name="l00948"></a>00948         result(2,3) = z;
<a name="l00949"></a>00949 
<a name="l00950"></a>00950         <span class="keywordflow">return</span> result;
<a name="l00951"></a>00951         }
<a name="l00952"></a>00952 
<a name="l00953"></a><a class="code" href="classQVMatrix.html#a065ea0cfb0a40679039c539bf4bb76b6">00953</a> <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> <a class="code" href="classQVMatrix.html#a065ea0cfb0a40679039c539bf4bb76b6" title="Obtains the mean vector for the column vectors in the matrix.">QVMatrix::meanCol</a>()<span class="keyword"> const</span>
<a name="l00954"></a>00954 <span class="keyword">        </span>{
<a name="l00955"></a>00955         <a class="code" href="classQVVector.html" title="Implementation of numerical vectors.">QVVector</a> result = <a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa" title="Gets a column of the matrix.">getCol</a>(0);
<a name="l00956"></a>00956         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(); i++)
<a name="l00957"></a>00957                 result += <a class="code" href="classQVMatrix.html#a476e9d1714f98c1ae1b7c1d396fcdbaa" title="Gets a column of the matrix.">getCol</a>(i);
<a name="l00958"></a>00958         <span class="keywordflow">return</span> result / <a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>();
<a name="l00959"></a>00959         }
<a name="l00960"></a>00960 
<a name="l00962"></a>00962 
<a name="l00963"></a><a class="code" href="group__qvmath.html#gaabdd51683148ac1153014120c7558b89">00963</a> std::ostream&amp; operator &lt;&lt; ( std::ostream &amp;os, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix )
<a name="l00964"></a>00964         {
<a name="l00965"></a>00965         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = matrix.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), rows = matrix.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>(), precision = os.precision();
<a name="l00966"></a>00966 
<a name="l00967"></a>00967         os &lt;&lt; <span class="stringliteral">&quot;QVMatrix (&quot;</span> &lt;&lt; rows &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; cols &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; std::endl;
<a name="l00968"></a>00968 
<a name="l00969"></a>00969         <span class="keyword">const</span> <span class="keywordtype">double</span> *data = matrix.<a class="code" href="classQVMatrix.html#a50de15cc657c8a1d9fcc749161192a64" title="Gets a read-only reference to the data buffer of the matrix.">getReadData</a>();
<a name="l00970"></a>00970         os &lt;&lt; <span class="stringliteral">&quot;[&quot;</span> &lt;&lt; std::endl;
<a name="l00971"></a>00971         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i &lt; rows; i++)
<a name="l00972"></a>00972                 {
<a name="l00973"></a>00973                 os &lt;&lt; <span class="stringliteral">&quot;    [ &quot;</span>;
<a name="l00974"></a>00974                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l00975"></a>00975                         {
<a name="l00976"></a>00976                         <span class="keyword">const</span> <span class="keywordtype">double</span> value = data[i*cols + j];
<a name="l00977"></a>00977                         os &lt;&lt; qPrintable(QString(<span class="stringliteral">&quot;%1&quot;</span>).arg(value, -(2+precision), <span class="charliteral">&#39;f&#39;</span>, precision)) &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
<a name="l00978"></a>00978                         }
<a name="l00979"></a>00979                 os &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> &lt;&lt; std::endl;
<a name="l00980"></a>00980                 }
<a name="l00981"></a>00981         os &lt;&lt; <span class="stringliteral">&quot;]&quot;</span> &lt;&lt; std::endl;
<a name="l00982"></a>00982         <span class="keywordflow">return</span> os;
<a name="l00983"></a>00983         }
<a name="l00984"></a>00984 
<a name="l00985"></a><a class="code" href="group__qvmath.html#ga20cb79175099f4623dc53a96d9f1ce6c">00985</a> std::istream&amp; <a class="code" href="group__qvmath.html#ga20cb79175099f4623dc53a96d9f1ce6c">operator &gt;&gt; </a>( std::istream &amp;is, <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix )
<a name="l00986"></a>00986         {
<a name="l00987"></a>00987         matrix = <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a>();
<a name="l00988"></a>00988 
<a name="l00989"></a>00989         <span class="keywordtype">int</span> cols, rows;
<a name="l00990"></a>00990         <span class="keywordtype">double</span> value;
<a name="l00991"></a>00991 
<a name="l00992"></a>00992         is.ignore(256, <span class="charliteral">&#39;(&#39;</span>);
<a name="l00993"></a>00993         <span class="keywordflow">if</span> (is.eof())
<a name="l00994"></a>00994                 <span class="keywordflow">return</span> is;
<a name="l00995"></a>00995 
<a name="l00996"></a>00996         is &gt;&gt; rows;
<a name="l00997"></a>00997 
<a name="l00998"></a>00998         is.ignore(256, <span class="charliteral">&#39;,&#39;</span>);
<a name="l00999"></a>00999         <span class="keywordflow">if</span> (is.eof())
<a name="l01000"></a>01000                 <span class="keywordflow">return</span> is;
<a name="l01001"></a>01001 
<a name="l01002"></a>01002         is &gt;&gt; cols;
<a name="l01003"></a>01003 
<a name="l01004"></a>01004         is.ignore(256, <span class="charliteral">&#39;[&#39;</span>);
<a name="l01005"></a>01005         <span class="keywordflow">if</span> (is.eof())
<a name="l01006"></a>01006                 <span class="keywordflow">return</span> is;
<a name="l01007"></a>01007 
<a name="l01008"></a>01008         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> maux(rows, cols);
<a name="l01009"></a>01009 
<a name="l01010"></a>01010         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; rows; i++)
<a name="l01011"></a>01011                 {
<a name="l01012"></a>01012                 is.ignore(256, <span class="charliteral">&#39;[&#39;</span>);
<a name="l01013"></a>01013                 <span class="keywordflow">if</span> (is.eof())
<a name="l01014"></a>01014                         <span class="keywordflow">return</span> is;
<a name="l01015"></a>01015 
<a name="l01016"></a>01016                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; cols; j++)
<a name="l01017"></a>01017                         {
<a name="l01018"></a>01018                         is &gt;&gt; value;
<a name="l01019"></a>01019                         maux(i, j) = value;
<a name="l01020"></a>01020                         }
<a name="l01021"></a>01021                 }
<a name="l01022"></a>01022 
<a name="l01023"></a>01023         matrix = maux;
<a name="l01024"></a>01024 
<a name="l01025"></a>01025         <span class="keywordflow">return</span> is;
<a name="l01026"></a>01026         }
<a name="l01027"></a>01027 
<a name="l01028"></a>01028 
<a name="l01029"></a><a class="code" href="group__qvmath.html#gaa3314730bd45d74b2a4f3cb8bd3fa0fa">01029</a> uint qHash(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l01030"></a>01030         {
<a name="l01031"></a>01031         <span class="keyword">const</span> <span class="keywordtype">int</span> cols = matrix.<a class="code" href="classQVMatrix.html#a420bba03aeccbd18161418049a025f66" title="Get width of the matrix.">getCols</a>(), rows = matrix.<a class="code" href="classQVMatrix.html#a4108aa685baecab8a9822dcc04e98b7f" title="Get height of the matrix.">getRows</a>();
<a name="l01032"></a>01032 
<a name="l01033"></a>01033         <span class="keywordtype">double</span> accum = 0;
<a name="l01034"></a>01034         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; cols; i++)
<a name="l01035"></a>01035                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; rows; j++)
<a name="l01036"></a>01036                         accum += matrix(i,j) / matrix(cols-i-1, rows-j-1);
<a name="l01037"></a>01037 
<a name="l01038"></a>01038         <span class="keywordflow">return</span> (uint) ((100000 * accum) / ((<span class="keywordtype">double</span>) (cols + rows)));
<a name="l01039"></a>01039         }
<a name="l01040"></a>01040 
<a name="l01041"></a>01041 
<a name="l01042"></a>01042 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l01043"></a>01043 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l01044"></a>01044 <span class="preprocessor">#include &lt;iomanip&gt;</span>
<a name="l01045"></a>01045 
<a name="l01046"></a><a class="code" href="group__qvmath.html#ga9ead752411a6772cfd7d75051cdc677e">01046</a> <span class="keywordtype">bool</span> <a class="code" href="group__qvmath.html#ga9ead752411a6772cfd7d75051cdc677e" title="Writes the content of a QVMatrix object in an ASCII file.">writeQVMatrixToFile</a>(<span class="keyword">const</span> QString fileName, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix, <span class="keyword">const</span> <span class="keywordtype">int</span> precission)
<a name="l01047"></a>01047         {
<a name="l01048"></a>01048         std::ofstream stream;
<a name="l01049"></a>01049         stream.open(qPrintable(fileName));
<a name="l01050"></a>01050 
<a name="l01051"></a>01051         <span class="keywordflow">if</span> ( stream.fail() )
<a name="l01052"></a>01052                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01053"></a>01053 
<a name="l01054"></a>01054         stream &lt;&lt; std::setprecision (precission);
<a name="l01055"></a>01055         stream &lt;&lt; matrix;
<a name="l01056"></a>01056         stream.close();
<a name="l01057"></a>01057         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01058"></a>01058         }
<a name="l01059"></a>01059 
<a name="l01060"></a><a class="code" href="group__qvmath.html#gae1e1afa78741e92ed46d20b70830a4fc">01060</a> <span class="keywordtype">bool</span> <a class="code" href="group__qvmath.html#gae1e1afa78741e92ed46d20b70830a4fc" title="Reads the content of a QVMatrix object from an ASCII file.">readQVMatrixFromFile</a>(<span class="keyword">const</span> QString fileName, <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l01061"></a>01061         {
<a name="l01062"></a>01062         std::ifstream stream;
<a name="l01063"></a>01063         stream.open(qPrintable(fileName));
<a name="l01064"></a>01064 
<a name="l01065"></a>01065         <span class="keywordflow">if</span> ( stream.fail() )
<a name="l01066"></a>01066                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l01067"></a>01067 
<a name="l01068"></a>01068         stream &gt;&gt; matrix;
<a name="l01069"></a>01069         stream.close();
<a name="l01070"></a>01070         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01071"></a>01071         }
<a name="l01072"></a>01072 
<a name="l01073"></a><a class="code" href="qvmatrix_8h.html#a487146b8bf0d9fa878ac70f07db27ba9">01073</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="qvmatrix_8cpp.html#a487146b8bf0d9fa878ac70f07db27ba9" title="Matrix-scalar product.">operator*</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l01074"></a>01074         {
<a name="l01075"></a>01075         <span class="keywordflow">return</span> matrix.<a class="code" href="classQVMatrix.html#a75ac95f4f6c88b4354e4e8aeab5b13a1" title="Matrix-scalar product.">scalarProduct</a>(value);
<a name="l01076"></a>01076         }
<a name="l01077"></a>01077 
<a name="l01078"></a><a class="code" href="qvmatrix_8h.html#a7bd034eee5dffb1811c3012483e57f81">01078</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="qvmatrix_8cpp.html#a7bd034eee5dffb1811c3012483e57f81" title="Matrix-scalar addition.">operator+</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l01079"></a>01079         {
<a name="l01080"></a>01080         <span class="keywordflow">return</span> matrix.<a class="code" href="classQVMatrix.html#af1286b0c208cec68dd42e5411b210081" title="Matrix-scalar addition.">scalarAdd</a>(value);
<a name="l01081"></a>01081         }
<a name="l01082"></a>01082 
<a name="l01083"></a><a class="code" href="qvmatrix_8h.html#a5f3ee33a44f26d22ea440be723fe2858">01083</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="qvmatrix_8cpp.html#a5f3ee33a44f26d22ea440be723fe2858" title="Matrix-scalar substraction operator.">operator-</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> value, <span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;matrix)
<a name="l01084"></a>01084         {
<a name="l01085"></a>01085         <span class="keywordflow">return</span> matrix.<a class="code" href="classQVMatrix.html#a6980327fe32d68ae6028482a8a96200e" title="Matrix-scalar substraction.">scalarSubstract</a>(value);
<a name="l01086"></a>01086         }
<a name="l01087"></a>01087 
<a name="l01088"></a>01088 
<a name="l01089"></a>01089 <span class="preprocessor">#ifndef DOXYGEN_IGNORE_THIS</span>
<a name="l01090"></a>01090 <span class="preprocessor"></span><span class="comment">// This function is based on code from the TooN library:</span>
<a name="l01091"></a>01091 <span class="comment">//      http://mi.eng.cam.ac.uk/~twd20/TooNhtml/</span>
<a name="l01092"></a>01092 <span class="keywordtype">void</span> rodrigues_so3_exp(<span class="keyword">const</span> <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a> &amp;w, <span class="keyword">const</span> <span class="keywordtype">double</span> A, <span class="keyword">const</span> <span class="keywordtype">double</span> B, <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;R)
<a name="l01093"></a>01093         {
<a name="l01094"></a>01094         <span class="keyword">const</span> <span class="keywordtype">double</span>    wx2 = w[0]*w[0],
<a name="l01095"></a>01095                         wy2 = w[1]*w[1],
<a name="l01096"></a>01096                         wz2 = w[2]*w[2],
<a name="l01097"></a>01097                         a1 = A*w[2],
<a name="l01098"></a>01098                         a2 = A*w[1],
<a name="l01099"></a>01099                         a3 = A*w[0],
<a name="l01100"></a>01100                         b1 = B*(w[0]*w[1]),
<a name="l01101"></a>01101                         b2 = B*(w[0]*w[2]),
<a name="l01102"></a>01102                         b3 = B*(w[1]*w[2]);
<a name="l01103"></a>01103 
<a name="l01104"></a>01104         R(0,0) = 1.0 - B*(wy2 + wz2);
<a name="l01105"></a>01105         R(1,1) = 1.0 - B*(wx2 + wz2);
<a name="l01106"></a>01106         R(2,2) = 1.0 - B*(wx2 + wy2);
<a name="l01107"></a>01107         R(0,1) = b1 - a1;
<a name="l01108"></a>01108         R(1,0) = b1 + a1;
<a name="l01109"></a>01109         R(0,2) = b2 + a2;
<a name="l01110"></a>01110         R(2,0) = b2 - a2;
<a name="l01111"></a>01111         R(1,2) = b3 - a3;
<a name="l01112"></a>01112         R(2,1) = b3 + a3;
<a name="l01113"></a>01113         }
<a name="l01114"></a>01114 <span class="preprocessor">#endif // DOXYGEN_IGNORE_THIS</span>
<a name="l01115"></a>01115 <span class="preprocessor"></span><span class="comment">// This function is based on code from the TooN library:</span>
<a name="l01116"></a>01116 <span class="comment">//      http://mi.eng.cam.ac.uk/~twd20/TooNhtml/</span>
<a name="l01117"></a><a class="code" href="group__qvmath.html#gad9a79664f7af4487d5af8fe2296fc7a4">01117</a> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> <a class="code" href="group__qvmath.html#gad9a79664f7af4487d5af8fe2296fc7a4" title="Obtains the rotation matrix corresponding to the element from the Lie algebra so(3)...">expSO3</a>(<span class="keyword">const</span> <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a>&amp; w)
<a name="l01118"></a>01118         {
<a name="l01119"></a>01119         <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> one_6th = 1.0/6.0, one_20th = 1.0/20.0;
<a name="l01120"></a>01120         <span class="keyword">const</span> <span class="keywordtype">double</span>    theta_sq = w*w,
<a name="l01121"></a>01121                         theta = sqrt(theta_sq),
<a name="l01122"></a>01122                         inv_theta = 1.0/theta;
<a name="l01123"></a>01123 
<a name="l01124"></a>01124         <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> result(3,3,0.0);
<a name="l01125"></a>01125         <span class="keywordflow">if</span> (theta_sq &lt; 1e-8)
<a name="l01126"></a>01126                 rodrigues_so3_exp(w, 1.0 - one_6th * theta_sq, 0.5, result);
<a name="l01127"></a>01127         <span class="keywordflow">else</span>    {
<a name="l01128"></a>01128                 <span class="keywordflow">if</span> (theta_sq &lt; 1e-6)
<a name="l01129"></a>01129                         rodrigues_so3_exp(w,    1.0 - theta_sq * one_6th*(1.0 - one_20th * theta_sq),
<a name="l01130"></a>01130                                                 0.5 - 0.25 * one_6th * theta_sq, result);
<a name="l01131"></a>01131                 <span class="keywordflow">else</span>
<a name="l01132"></a>01132                         rodrigues_so3_exp(w,    sin(theta) * inv_theta,
<a name="l01133"></a>01133                                                 (1 - cos(theta)) * (inv_theta * inv_theta),
<a name="l01134"></a>01134                                                 result);
<a name="l01135"></a>01135                 }
<a name="l01136"></a>01136         <span class="keywordflow">return</span> result;
<a name="l01137"></a>01137         }
<a name="l01138"></a>01138 
<a name="l01139"></a>01139 <span class="comment">// This function is based on code from the TooN library:</span>
<a name="l01140"></a>01140 <span class="comment">//      http://mi.eng.cam.ac.uk/~twd20/TooNhtml/</span>
<a name="l01141"></a><a class="code" href="group__qvmath.html#ga85e11a75a24eec1686a939aa690e1942">01141</a> <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a> <a class="code" href="group__qvmath.html#ga85e11a75a24eec1686a939aa690e1942" title="Obtains the element from the Lie algebra so(3) corresponding to a rotation matrix...">lnSO3</a>(<span class="keyword">const</span> <a class="code" href="classQVMatrix.html" title="Implementation of numerical matrices.">QVMatrix</a> &amp;R)
<a name="l01142"></a>01142         {
<a name="l01143"></a>01143         <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a> result( (R(2,1)-R(1,2))/2, (R(0,2)-R(2,0))/2, (R(1,0)-R(0,1))/2 );
<a name="l01144"></a>01144 
<a name="l01145"></a>01145         <span class="keyword">const</span> <span class="keywordtype">double</span> cos_angle = (R(0,0) + R(1,1) + R(2,2) - 1.0) * 0.5;
<a name="l01146"></a>01146 
<a name="l01147"></a>01147         <span class="keywordtype">double</span> sin_angle_abs = result.<a class="code" href="classQVVector.html#a49c6f41f1fa80efcc943f1c26fdcbf05" title="Norm 2 of the vector.">norm2</a>();
<a name="l01148"></a>01148         <span class="keywordflow">if</span> (cos_angle &gt; M_SQRT1_2)
<a name="l01149"></a>01149                 <span class="comment">// [0 - Pi/4[ use asin</span>
<a name="l01150"></a>01150                 {
<a name="l01151"></a>01151                 <span class="keywordflow">if</span>(sin_angle_abs &gt; 0)
<a name="l01152"></a>01152                         result = result * asin(sin_angle_abs) / sin_angle_abs;
<a name="l01153"></a>01153                 }
<a name="l01154"></a>01154         <span class="keywordflow">else</span> <span class="keywordflow">if</span>( cos_angle &gt; -M_SQRT1_2)
<a name="l01155"></a>01155                 <span class="comment">// [Pi/4 - 3Pi/4[ use acos, but antisymmetric part</span>
<a name="l01156"></a>01156                 result = result * acos(cos_angle) / sin_angle_abs;
<a name="l01157"></a>01157         <span class="keywordflow">else</span>    <span class="comment">// Rest use symmetric part</span>
<a name="l01158"></a>01158                 {
<a name="l01159"></a>01159                 <span class="comment">// Antisymmetric part vanishes, but still large rotation, need information from symmetric part</span>
<a name="l01160"></a>01160                 <span class="keyword">const</span> <span class="keywordtype">double</span>    d0 = R(0,0) - cos_angle,
<a name="l01161"></a>01161                                 d1 = R(1,1) - cos_angle,
<a name="l01162"></a>01162                                 d2 = R(2,2) - cos_angle;
<a name="l01163"></a>01163 
<a name="l01164"></a>01164                 <span class="keyword">const</span> <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a> r2 = (fabs(d0) &gt; fabs(d1) &amp;&amp; fabs(d0) &gt; fabs(d2))?
<a name="l01165"></a>01165                                         <span class="comment">// first is largest, fill with first column</span>
<a name="l01166"></a>01166                                         <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a>(d0, (R(1,0)+R(0,1))/2, (R(0,2)+R(2,0))/2):
<a name="l01167"></a>01167                                         (fabs(d1) &gt; fabs(d2))?
<a name="l01168"></a>01168                                                 <span class="comment">// second is largest, fill with second column</span>
<a name="l01169"></a>01169                                                 <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a>((R(1,0)+R(0,1))/2, d1, (R(2,1)+R(1,2))/2):
<a name="l01170"></a>01170                                                 <span class="comment">// third is largest, fill with third column</span>
<a name="l01171"></a>01171                                                 <a class="code" href="classQV3DPointF.html" title="3D point representation">QV3DPointF</a>((R(0,2)+R(2,0))/2, (R(2,1)+R(1,2))/2, d2);
<a name="l01172"></a>01172 
<a name="l01173"></a>01173                 <span class="comment">// Flip if we point in the wrong direction! Also, norm of result vector = angle.</span>
<a name="l01174"></a>01174                 result = r2 * ((r2 * result &lt; 0)?-1.0:1.0) * (M_PI - asin(sin_angle_abs)) / r2.<a class="code" href="classQVVector.html#a49c6f41f1fa80efcc943f1c26fdcbf05" title="Norm 2 of the vector.">norm2</a>();
<a name="l01175"></a>01175                 }
<a name="l01176"></a>01176         <span class="keywordflow">return</span> result;
<a name="l01177"></a>01177         }
</pre></div></div>
</td></tr></table>

<br /><hr><br />
<center><a href="http://perception.inf.um.es/QVision">QVision framework</a>.
<a href="http://perception.inf.um.es">PARP research group</a>.
Copyright &copy; 2007, 2008, 2009, 2010, 2011.</center>
<br />
</body>
</html>
